Nginx 配置转发到其他站点

80 url转发

/etc/nginx/conf.d/

目录底下新建一个

my80.conf

server {
    listen   80;
    server_name  127.0.0.1;
    root         /usr/share/nginx/html;

    location /my/swagger {            
            proxy_pass http://127.0.0.1:5000/swagger;
            proxy_set_header Host $proxy_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Via "nginx";
        }
    location /my/api {            
            proxy_pass http://127.0.0.1:5000/api;
            proxy_set_header Host $proxy_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Via "nginx";
        }

    # Load configuration files for the default server block.
    location /{
            proxy_pass http://127.0.0.1:8091;
            proxy_set_header Host $proxy_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Via "nginx";
        }

        error_page 404 /404.html;
        location = /404.html {
        }

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

}
原文地址:https://www.cnblogs.com/mrguoguo/p/14816643.html