how to reverse proxy via nginx a specific url?

前端 未结 2 1477
别跟我提以往
别跟我提以往 2021-01-20 10:41

I have a server running at http://localhost:8080 i want a specific url of this server to be proxied by nginx.

For example, i only want http://loc

2条回答
  •  难免孤独
    2021-01-20 11:18

    I made it somehow this way and it worked. Thanks for your comment anyway. :)

    server {
        listen 80;
        # ... other stuff
    
        upstream backend1 {
            server 127.0.0.1:8080;
        }
    
        location /test/ {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_pass http://backend1/test/;
        }
    }
    

提交回复
热议问题