proxy_pass Not Working on Port 80

figshta nginx-forum at forum.nginx.org
Wed Sep 9 14:40:35 UTC 2020


Thank you Francis and Rennis.
I really appreciate your help, unfortunately it isn't working yet...

Are there any another ways to trouble shoot this port problem?

Rennis: 
Your suggestion looked so promising.
 
> In this configuration nginx doesn't pass the Host header to backend.
> In case there are multiple name based virtualhosts on the 192.168.3.5,
> you'll always get the default or first one (the order in the backend
> config).

It really makes sense because I do have another configuration pointing to
this backend server; it is, however, on port 443.

Here is the complete proxy configuration for both sites on Server1: (I added
the proxy_set_header directive as suggestedl)

#Proxy server (Pi3) (Server1)
# houseofavi.com server
server {
        listen 443;
        server_name houseofavi.com;
        location / {
                proxy_pass              https://192.168.3.5:443;
                proxy_set_header        Host $host;
        }

    ssl_certificate /etc/letsencrypt/live/houseofavi.com/fullchain.pem; #
managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/houseofavi.com/privkey.pem; #
managed by Certbot
}

# threedaystubble.com server
server {
        listen 80;
        server_name www.threedaystubble.com threedaystubble.com;
        location / {
                proxy_pass              http://192.168.3.5:80;
                proxy_set_header        Host $host;
        }
}

Are there another ideas to allow port 80?

Francis:

I don't want to use port 8080 or 8081 because Certbot requires port 80 and
it should work. 
I plan to have everything on port 443 once it's all set up. 
I am however, now concerned about running into trouble with multiple sites
using 443.
It it difficult?
I hope I can pass various requests to different "virtual" server blocks on
the same port.

Here both server configurations on Server2 in case it helps.

#Proxied Server (Server2)
#houseofavi.com
server {
        if ($host = houseofavi.com) {
                        return 301 https://$host$request_uri;
        } # managed by Certbot
        server_name houseofavi.com;
        return 404; # managed by Certbot
        root /var/www/houseofavi.com;
}

server {
        listen 443 ssl; # managed by Certbot
        root /var/www/houseofavi.com;
        location / {
        }
        ssl_certificate /etc/letsencrypt/live/houseofavi.com/fullchain.pem;
# managed by Certbot
        ssl_certificate_key
/etc/letsencrypt/live/houseofavi.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by
Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

#Proxied Server (Server2)
#threedaystubble.com
server {
        listen 80;
        server_name threedaystubble.com www.threedaystubble.com;
        root /var/www/threedaystubble.com;
        location / {
        }
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,289348,289362#msg-289362



More information about the nginx mailing list