若依前后端分离nginx部署

前端打包 /ruoyi/projects/ruoyi-ui
npm run build:prod


start nginx : 启动nginx

nginx -s reload  :修改配置后重新加载生效

nginx -s reopen  :重新打开日志文件

nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:

nginx -s stop  :快速停止nginx

nginx -s quit  :完整有序的停止nginx

部署和配置nginx的nginx.conf的文件

server {
			listen       81;
			server_name  服务的名字;
			location / {
				root   D:/dist/;
				try_files $uri $uri/ /index.html;
                index  index.html index.htm;
			}
	
			location /dev-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:port/;
				proxy_connect_timeout 6000s;
				proxy_read_timeout  6000s;
				proxy_send_timeout  6000s;
			}
	
			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:port/;
				proxy_connect_timeout 6000s;
				proxy_read_timeout  6000s;
				proxy_send_timeout  6000s;
			}
			location /profile/{
			   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:port/profile/;
			   client_max_body_size  100m;
				 client_body_buffer_size 256k;
				 proxy_connect_timeout 6000s;
				 proxy_read_timeout  6000s;
				 proxy_send_timeout  6000s;
				 proxy_buffer_size  32k;
				 proxy_buffers   4 64k;
				 proxy_busy_buffers_size 128k;
				 proxy_temp_file_write_size 10m;
		  }
		error_page   500 502 503 504  /50x.html;
		location = /50x.html {
				root   html;
		}
		
	}


检查配置文件的命令
nginx -t -c /nginx-1.18.0/conf/nginx.conf


启动命令
start nginx
检查服务启动是否正常命令
tasklist /fi "imagename eq nginx.exe"

 

 

posted @ 2022-09-03 11:23  张载zz  阅读(3911)  评论(0编辑  收藏  举报