Jump to content
XPEnology Community

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


latonita

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
Link to comment
Share on other sites

  • 1 month later...

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...