RuoYi若依部署前端时,nginx配置错误解决

createh510小时前技术教程1

需要部署 若依RuoYi-Vue前后端分离的后台管理系统时,后端正常,但是前端保存。

 若依的地址:https://doc.ruoyi.vip/ruoyi-vue/

前端需要nginx,在windows10系统上,nginx部署运行正常。

但是RuoYi-Vue前端部署在端口7079,运行报错。

nginx保存信息的log文件内容如下:

uoyi-ui/index.html" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:7079", referrer: "http://127.0.0.1:7079/"
2025/03/28 12:34:23 [crit] 9428#11860: *5 GetFileAttributesEx() "E:	emp

uoyi-ui/index.html" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost, request: "GET /index HTTP/1.1", host: "127.0.0.1:7079"
2025/03/28 12:46:04 [crit] 9428#11860: *9 GetFileAttributesEx() "E:	emp
uoyi-ui/index.html" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost, request: "GET /index HTTP/1.1", host: "127.0.0.1:7079"
2025/03/28 12:46:04 [crit] 9428#11860: *9 GetFileAttributesEx() "E:	emp
uoyi-ui/index.html" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost, request: "GET /index HTTP/1.1", host: "127.0.0.1:7079"
2025/03/28 12:46:04 [crit] 9428#11860: *9 GetFileAttributesEx() "E:	emp
uoyi-ui/index.html" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost, request: "GET /index HTTP/1.1", host: "127.0.0.1:7079"
2025/03/28 12:46:04 [error] 9428#11860: *9 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: localhost, request: "GET /index HTTP/1.1", host: "127.0.0.1:7079"

经分析,是windows下的nginx的配置信息存在错误,关键信息如下:

    server {
        listen       7079;
        server_name  localhost;
		charset utf-8;

		location / {
            root   E:\temp\ruoyi-ui;
			try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }
		
		location /prod-api/ {
			proxy_set_header Host $http_host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://127.0.0.1:8081/;
		}

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

里面的目录E:\temp\ruoyi-ui

就是前端部署文件,经分析,应采用正斜杠/,也就是正确的应该是:

E:/temp/ruoyi-ui

修改nginx配置后,正常运行如下:

相关文章

Nginx proxy_pass 后缀斜杠规则(随手存)

例如本地80端口Nginx代理9999端口服务,客户端访问 http://127.0.0.1/AAAA/BBBB情况1:location /AAAA/ { proxy_pass http://...

面试必问-分布式技术:限流、通讯、缓存,你都懂了吗?

分布式可以说是在面试当中肯定会问到的问题,有些小伙伴也开始准备接下来的面试了,所以今天特地来总结一波分布式技术专题面试,限流、通讯、缓存:Nginx+ZooKeeper+ActiveMQ+Kafka+...

一文掌握 Linux 符号链接

符号链接(Symbolic Link),通常被称为“软链接”,是 Linux 文件系统中一种强大而灵活的工具。它允许用户创建指向文件或目录的“快捷方式”,不仅简化了文件管理,还在系统配置、软件开发和日...

RuoYi若依框架 前端 部署[具体步骤]

RuoYi若依框架前端部署本文部署的若依版本是3.8.9,服务器操作系统windows 10。下载地址:https://gitee.com/y_project/RuoYi-Vue一. 所需环境若依后端...

Nginx核心指令listen与server_name入门

在nginx.conf配置文件中有常见且重要的指令,在Nginx中nginx.conf配置文件详解 中介绍了一部分,下面将对listen和server_name进行介绍。1.listen(1)含义指定...