Keep getting "Welcome to nginx!" with nginx proxy

(Its late here so forgive I miss understood - or I have forgot something)

You are trying to proxy requests on port 80 is that required ?

This is a working proxy config file for the proxy instance put this in /etc/nginx/sites-enabled/default - it redirects all HTTP requests to HTTPS then “proxies them” to HTTP servers we then have 2 server blocks for each domain - I dont include all the lets encrypt params because I dont have time to get letsencrypt setup here

// Redirect all requests to https
server {
    listen 80;
    return 301 https://$host$request_uri;
}
// Proxy requests for cool_website.com
server {
    listen 443;
    server_name YOUR_DOMAIN_NAME;

    ssl_certificate               /etc/letsencrypt/cert_path;
    ssl_certificate_key           /etc/letsencrypt/key_path;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy "origin";


    access_log            /var/log/nginx/YOUR_DOMAIN_NAME.access.log;

    location / {
      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      proxy_pass          http://YOUR_NGINX_CONTAINER_DOMAIN_NAME:80;
      proxy_read_timeout  90;

      proxy_redirect      http://YOUR_NGINX_CONTAINER_DOMAIN_NAME:80 YOUR_DOMAIN_NAME;
    }
}
// Proxy requests for less_cool_website.com
server {
    listen 443;
    server_name YOUR_SECOND_DOMAIN;

    ssl_certificate           /etc/lets_encrypt/another_cert/cert.crt;
    ssl_certificate_key       /etc/lets_encrypt/another_cert/key.key

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy "origin";

    access_log            /var/log/nginx/YOUR_SECOND_DOMAIN.access.log;

    location / {
      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      proxy_pass          http://YOUR_OTHER_NGINX_WEBSITE_CONTAINER:80;
      proxy_read_timeout  90;

      proxy_redirect      http://YOUR_OTHER_NGINX_WEBSITE_CONTAINER.lxd:80 YOUR_SECOND_DOMAIN;
    }
}

On the nginx containers - I just left the default installed nginx config file as it was and this proxied the requests to them no problem, did I miss something?

Put listen [::]:80 in your website containers nginx config file to make sure its also listening on ipv6 (which lxd will use by default)

1 Like