Nginx reverse proxy

Questions about HTTP Access/Mods may go here
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:

https://account.synology.com/support/support_form.php?lang=enu



2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
tetzuo
I'm New!
I'm New!
Posts: 2
Joined: Fri Dec 18, 2015 9:10 am

Nginx reverse proxy

Postby tetzuo » Wed Jan 18, 2017 8:19 am

Hi,

I have a working Nginx reverse proxy, I can go to https://domain.com/service1, I have manually edited the file server.Reverseproxy.conf in the folder /etc/nginx/app.d/ because I couldnt figure out how to set it up in the DSM Gui.
The problem is everytime I reboot or update webstation (and sometimes randomly) DSM overwrites my nginx config. Is there anyway to get below config setup directly in the DSM Gui, or force the DSM to import my config? other suggestions?
To solve this temporary I copied my server.Reverseproxy.conf to another location and just copy it and overwrite the one in /etc/nginx/app.d/ and then reload nginx with sudo nginx -s reload
Thank you

Below is the content of my server.Reverseproxy.conf:

server {
listen 443 ssl;
listen [::]:443 ssl;

server_name domain.com;

ssl_certificate /usr/syno/etc/certificate/ReverseProxy/a7154522-c221-4d6b-af25-125df824f22b/fullchain.pem;

ssl_certificate_key /usr/syno/etc/certificate/ReverseProxy/a7154522-c221-4d6b-af25-125df824f22b/privkey.pem;

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_pass http://127.0.0.1:6000;
}
location /service1 {
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_pass http://127.0.0.1:6001;
}
location /service2 {
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_pass http://127.0.0.1:6002;
}
location /service3 {
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_pass http://127.0.0.1:6003;
}
location /service4 {
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_pass http://127.0.0.1:6004;
}
}
tetzuo
I'm New!
I'm New!
Posts: 2
Joined: Fri Dec 18, 2015 9:10 am

Re: Nginx reverse proxy

Postby tetzuo » Thu Jan 19, 2017 2:07 pm

I ended up doing a script that copy the config file from another location and then reloads the nginx service every reboot.
I take no responsibility for below info everything you mod on your synology is your responsibility.

If anybody wants to do this dirty workaround here is a little guide to get you started
ssh to your synology
sudo vi nginx.sh
paste the following in the file:

Code: Select all

#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin
sudo cp /volume1/Media/backup/server.ReverseProxy.conf /etc/nginx/app.d/server.ReverseProxy.conf
sudo nginx -s reload

Save the file and the chmod it to your liking preferably -x (sudo chmod +x nginx.sh)
goto DSM gui and create a triggered task set it to run at boot up and point out the script we created above.
Dufooy
I'm New!
I'm New!
Posts: 1
Joined: Sat Oct 14, 2017 10:10 am

Re: Nginx reverse proxy

Postby Dufooy » Sat Oct 14, 2017 12:14 pm

Hi and thank you for this great Skript.
It works perfect, the only thing is, if I setup a redirect to the Photostation, the I get error Messages in the Browsers.
Intrude Ff even...

This is the Error

Code: Select all

FeFehler 400 Bad Request Request Header Or Cookie Too Large nginx.


Some one of wrote that it probably hast to do whit large_client_header_buffers

Any one a Idea about this?

Best D.

Return to “HTTP/Apache Mods”

Who is online

Users browsing this forum: No registered users and 2 guests