Score:1

How can I setup a nginx reverse proxy to display sites on different servers on my network to different specific domains

cw flag

So far I have this for my reverse proxy settings:

 server {
        server_name subdomain1.DOMAIN.net;
        location / {
            proxy_pass       http://192.168.1.156:9090;
        }
 }
 server {
        server_name subdomain2.DOMAIN.net;
        location / {
            proxy_pass       http://192.168.1.156:9091;
        }
 }

How ever it's just reporting back a 502 bad gateway when I check them. For more clarification nginx is running on a VM ubuntu server while the sites i'd like to access are running on another server on the same network. I'd like to know what i'm doing wrong here would really like to get it working.

Lex Li avatar
vn flag
Since every requests to the upstream servers are in HTTP, you can easily use a tool like Wireshark to analyze the requests/responses and learn what's wrong. Such 502 usually indicates that the upstream dislikes the requests. The packets can tell you more.
djdomi avatar
za flag
did you [read the manual?](https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/) most request require the domain name of it so far ```proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;``` should be always used in most cases
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.