Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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://localhost:8080/test/(.*) to be reverse proxied to http://localhost/test/(.*).

I'm proxing another server to http://localhost/.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

What about just a simple location block?

server {
    # ... other stuff

    location /test/ {
        try_files $uri @testproxy;
    }

    location @testproxy {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        # all your params
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...