To record, the nginx configuration under a domain name, and the server service interface api is configured at the same time, web-management terminal + web-doctor terminal, and the page is vue

web-management end-deployment address: /usr/local/yabei/web/platform access address: http://yabei.520ban.com/platform/ web-
doctor end-deployment address: /usr/local/yabei/web/ doctor visit address: http://yabei.520ban.com/doctor/
serer-api interface deployment address: /usr/local/yabei/web/server visit address: http://yabei.520ban.com

  • location ^~/doctor/yb/And location ^~/platform/yb/express vue did a forward, put on all interfaces /doctor/yb/, /platform/yb/need to do a forward to access to the interface
  • /platformAnd /doctorrepresent the two ends of the inlet, the forwarding address is to deploy
  • / Represents interface forwarding, which means deploying server, api interface forwarding

Insert picture description here

# 502 bad gateway 错误解决配置 start
proxy_buffer_size 64k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
# 502 bad gateway 错误解决配置 end

server {

    listen 80;
    server_name yabei.520ban.com;

    client_max_body_size     200m; #文件最大大小
    proxy_connect_timeout    600;  #设置超时时间
    proxy_read_timeout       600;
    proxy_send_timeout       600;


    location ^~/doctor/yb/ {
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Real-PORT $remote_port;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass http://127.0.0.1:9048/;
            error_page 405 =200 http://$host$request_uri;
    }

    location ^~/platform/yb/ {
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Real-PORT $remote_port;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass http://127.0.0.1:9048/;
            error_page 405 =200 http://$host$request_uri;
    }



    location /platform {
            alias /usr/local/yabei/web/platform/;         #静态资源路径
            index  index.html index.htm;
            try_files $uri $uri/ /index.html =404;
    }
 

    location /doctor {
            alias /usr/local/yabei/web/doctor/;         #静态资源路径
            index  index.html index.htm;
            try_files $uri $uri/ /index.html =404;
    }


    location / {
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Real-PORT $remote_port;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass http://127.0.0.1:9048;
            error_page 405 =200 http://$host$request_uri;
     }
}

Guess you like

Origin blog.csdn.net/qq_41463655/article/details/108366690