4

I'm trying to access my synology nas web ui behind a nginx reverse proxy running on my raspberry. Nginx reverse proxy is working for other stuff, like my ghost blog. I copy/pasted the settings to access my nas's 192.168.0.123:5000 via nas.my.domain, but I got a "Synology / Sorry, page not found" instead of DSM's login prompt.

Here is my nginx's settings

upstream nas {
       server 192.168.0.123:5001;
       # server 192.168.0.123:5000; KO
       # server 192.168.0.123; KO
}

server {
        listen 80;
        return 302 https://$server_name$request_uri;
}

server {
    server_name nas.my.domain;

    listen 443 ssl http2;
    # listen [::]:443 ssl http2;

    access_log  /var/log/nginx/nas.access.log;
    error_log   /var/log/nginx/nas.error.log;

        ssl_certificate /etc/letsencrypt/live/nas.my.domain/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/nas.my.domain/privkey.pem;
        include /etc/nginx/include/diffie-hellman;

        client_max_body_size 2m;

        location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff|)$ {
            access_log off;
            expires 30d;
            add_header Pragma public;
            add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
            proxy_pass https://nas;
        }

        location / {
            proxy_set_header HOST $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-NginX-Proxy true;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_pass https://nas;
            proxy_redirect off;
            proxy_buffering off;
        }

}

And inside the nas I set up Control Panel / External Access / Advanced with nas.my.domain http = 80 and https = 443.

Any ideas please to fix or troubleshoot this ?

Best regards,

Rémy
  • 286
  • 1
  • 2
  • 8
  • If you're using https, make sure you use port 5001 instead of 5000. – David W Dec 27 '16 at 22:45
  • Tried 5000 5001 80 and 443 already, both with `proxy_pass http://nas` and `proxy_pass https://nas`. Whenever using the wrong combinations, there's a specific error message. – Rémy Dec 28 '16 at 12:16

1 Answers1

1

I managed to get it working, not sure why

  • Only port 443 somehow reacted
  • It was all white before until I c/ced all the header from location / to location for image caching.
    upstream nas {
           server 192.168.0.123:443;
    }

    server {
            listen 80;
            return 302 https://$server_name$request_uri;
    }

    server {
        server_name nas.my.domain;

        listen 443 ssl http2;
        # listen [::]:443 ssl http2;

        access_log  /var/log/nginx/nas.access.log;
        error_log   /var/log/nginx/nas.error.log;

            ssl_certificate /etc/letsencrypt/live/nas.my.domain/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/nas.my.domain/privkey.pem;
            include /etc/nginx/include/diffie-hellman;

            client_max_body_size 2m;

            location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff|)$ {
                access_log off;
                expires 30d;
                add_header Pragma public;
                add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
                proxy_set_header HOST $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
                proxy_pass https://nas;
                proxy_redirect off;
                proxy_buffering off;
            }

            location / {
                proxy_set_header HOST $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-NginX-Proxy true;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
                proxy_pass https://nas;
                proxy_redirect off;
                proxy_buffering off;
            }

    }
Rémy
  • 286
  • 1
  • 2
  • 8