latonita

DSM 6.1 Nginx reverse proxy - can't make it work

Recommended Posts

Hi

i'm running DSM 6.1.4-15217 Update 5. Web station package installed.

I tried to configure simplest reverse proxy configuration: redirect http://server/path to docker container at http://localhost:port, however it looks like for some stupid reason it cant be done via UI - only port redirection is available. So configuration tweaks required.

 

I have read number of articles.  One of those is here https://tech.setepontos.com/2016/07/06/synology-dsm-6-web-station-virtual-hosts-settings/

Most of them tell to work with /usr/local/etc/nginx/sites-enabled/*

 

Ok. i created config file as below and put under that folder.

Reloaded configs with nginx -s reload. (and yes, it picks up config, i had syntax error in my file and it told me that)

server {
    listen 80;

    location /portainer {
        proxy_pass http://127.0.0.1:9000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

 

However, result is far from positive.  My server named tank.local. When i open http://tank.local/portainer i always get redirected to http://tank.local:5000

Tried other containers like grafana or node-red. same result.

Looked at server response : always getting 302 Moved permanently and redirection to http://tank.local:5000

 

I also inspected nginx.conf, tried to use another way - via /usr/loca/etc/nginx/conf.d/www.*.conf

same result. at some point i was getting 404, but after i did synoservicecfg --restart nginx i'm always getting 302 moved permanently

 

Any ideas?

 

 

Edited by latonita

Share this post


Link to post
Share on other sites

update: after reboot (just applied latest security patch) it stopped redirecting me (302). just always giving me 404

Share this post


Link to post
Share on other sites

Also interesting.

How to get the site (Prestashop) work with nginx. The site is in the directory /web:

/volume1/web/mysite

Now works with Apache 2.2.

Share this post


Link to post
Share on other sites
Posted (edited)

Hi @latonita

 

I have a feeling the server block is clashing with the existing configuration in /etc/nginx/nginx.conf
I have a server block for a port 80 listener which is the synology web service. Have a look in that config to see if there is an existing server listening on port 80.


Also just for clarity, is tank.local your synology/xpenology device. And is path based routing (using /portainer) your only option? do you have an internal dns server and could create a CNAME record to point at tank.local like "portainer.local CNAME tank.local" and then create a host reverse proxy in DSM Application Portal to create a reverse proxy like "portainer.local:80 -> localhost:9000"

I'd recommend against path based routing in nginx because of the number of synology location blocks being used and the chance that an upgrade could lose the configuration. And just for simplicity sake. I can provide additional assistance regardless of method, so if you have any additional questions I can try to assist some more.

Edited by shrabok

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now