0

I'm using NGINX to load balance a docker swarm cluster on Digital Ocean. I have swarmpit installed and I want to reverse proxy to it with an ssl certificate and using a custom port so that I can privately access it and restrict traffic.

I'm not using any custom paths or anything fancy. I'm literally just reverse proxying from the root path under a subdomain to the container.

The page does load but it seems like anything not in the root doesn't load and either comes up with a 404 or a 401 error. As a result the page appears broken with only the root-level content loading.

Server Config

server {
    listen #### ssl;

    ssl_certificate /etc/letsencrypt/live/###.#####.###/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/###.#####.###/privkey.pem;

    include snippets/ssl-params.conf;
    include snippets/optimize-assets.conf;

    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'Upgrade';
        proxy_cache_bypass $http_upgrade;
        proxy_pass http://swarmpit;
    }
}

Upstream Block

upstream swarmpit {
    server ###.###.###.###:###;
    server ###.###.###.###:###;
    server ###.###.###.###:###;
    server ###.###.###.###:###;
    server ###.###.###.###:###;
}

I also have many defaults set in the nginx.conf file such as

nginx.conf

...
    proxy_redirect          off;
    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_request_headers on;
...

What I'm seeing though is

Several 404 and 401 errors

An example of one of the 404 responses

Request URL: https://###.#####.###:####/css/rc-slider.css
Request Method: GET
Status Code: 404 Not Found
Remote Address: ###.###.###.###:####
Referrer Policy: no-referrer-when-downgrade
Connection: keep-alive
Content-Length: 555
Content-Type: text/html
Date: Sat, 30 May 2020 05:50:54 GMT
Server: nginx/1.18.0
Accept: text/css,*/*;q=0.1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: _ga=#####
DNT: 1
Host: ###.#####.###:####
Referer: https://###.#####.###:####/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.125

I'm not sure why this isn't working but I've run out of help after a lot of Googling and I'm sure it's something that's probably simple. Any help is appreciated.

June
  • 101
  • 1
  • I'm giving up by this point, I'm honestly giving up. I'll access it directly using HTTP and hope for the best. – June May 30 '20 at 16:29
  • What were the logs in swarmpit saying? – Khushil May 31 '20 at 09:58
  • @Khushil There's no log printout that I can find. I did discover something interesting on my end though just recently by mistake, a seperate error.log file read this `/etc/nginx/html/icon/favicon-32x32.png` which returned a 404. Now I know this can happen if you forget to set the root or index but I'm purely doing a reverse proxy and I haven't had this error with any of my other reverse proxies. Why is it this one in particular that's making NGINX look into the config files to serve up content instead of proxying it? – June Jun 01 '20 at 00:07

0 Answers0