Well, I’ve been tinkering with NGINX for a while at home, up till now I had a somewhat working reverse proxy setup (to access my stuff, when I’m not at home or away).
What didn’t work so far was the DSM web interface. Basically, because the interface is using absolute paths in some CSS/JS includes, which fuck up the whole interface.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<link rel="stylesheet" type="text/css" href="/scripts/ext-3/resources/css/ext-all.css?v=3211" /> <link rel="stylesheet" type="text/css" href="/scripts/ext-3/resources/css/xtheme-gray.css?v=3211" /> <link rel="stylesheet" type="text/css" href="/scripts/ext-3/ux/ux-all.css?v=3211" /> <link rel="stylesheet" type="text/css" href="resources/css/desktop.css?v=3211" /> <link rel="stylesheet" type="text/css" href="resources/css/flexcrollstyles.css?v=3211" /> ... <script type="text/javascript" src="/scripts/uistrings.cgi?lang=enu&v=3211"></script> <script type="text/javascript" src="/webfm/webUI/uistrings.cgi?lang=enu&v=3211"></script> <script type="text/javascript" src="uistrings.cgi?lang=enu&v=3211"></script> <script type="text/javascript" src="/scripts/prototype-1.6.1/prototype.js?v=3211"></script> <script type="text/javascript" src="/scripts/ext-3/adapter/ext/ext-base.js?v=3211"></script> <script type="text/javascript" src="/scripts/ext-3/ext-all.js?v=3211"></script> <script type="text/javascript" src="/scripts/ext-3/ux/ux-all.js?v=3211"></script> <script type="text/javascript" src="/scripts/scrollbar/flexcroll.js?v=3211"></script> |
After some googling and looking through the NGINX documentation I thought “Why don’t I create a vHost for each application that is being served by the reverse proxy?”.
And after looking further into the documentation, out came this simple reverse proxy statement:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
server { listen 80; server_name syno.heimdaheim.de; location / { proxy_pass http://172.31.76.50:5000/; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect http://172.31.76.50:5000/ http://$host:$server_port/; proxy_buffering off; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/htpasswd; } } |
And as you can see, it works:
Cool! Just wondering if you have a tutorial for setting up nginx on synology DS1512+ in particular.
Nope, the NGINX reverse proxy is outside of the DiskStation.
Hi,
Thanks for your post.
I’m having troubles to configure mine. Could you please describe why you are using the auth_basic and auth_basic_user_file statement ?
And finaly, is your nginx reverse proxy sitting on the DiskStation ? (Mine is on a dedicated machine)
Hey misterneno,
I’m using auth_basic and auth_basic_user_file since the reverse proxy is available from the Internet. Even if the DiskStation has it’s own password database, I wanted an additional level.
The NGINX is running on a dedicated machine (same as yours then).
Hey,
Thanks for the tip, I found your webpage looking for how to install nginx on synology, do you have a nice tutorial for that?
Once installed, I will definitely try your trick! Can’t wait!
/glattering
Hey glattering,
as I stated above, the NGINX reverse proxy is running on another system. But it should be as simple as replacing the proxy-pass/proxy-redirect ips with 127.0.0.1.
Hello again,
It’s been a while…
I heard I can use nginx on my router.
I have an ASUS RTN16 running Tomato.
DO you know where I could find information on how to install nginx on Tomato?
I have been searching without success.
I also heard some version of tomato include already nginx but I couldn’t find how to find out if my version of tomato has it or not.
Any help is welcome 🙂
Glattering, I have a ASUS RTN16 too. Instead of Tomato, I am using TomatoRAF (a version that is still being updated) You can find it here:
http://victek.is-a-geek.com/
In that version, under webserver you have the option to turn nginx on or off and to save custom configuration. Up until recently I was using that nginx as a reverse proxy.
Hi,
I have NGINX running on a raspberrypi and I also want to access my DSM via a reverse proxy. Unfortunately I don’t have the option to use subdomains. I can only use paths. I managed to get it working, at least partially. I can log in and do some of the things, but I cannot e.g. open the FileManager because of some script error. I suppose it’s still a miss configuration of my reverse proxy. Maybe someone has an idea. In order to have a workaround for the absolute paths I used a rewrite in the root location with a condition.
server {
client_max_body_size 2m;
listen 443 ssl spdy;
server_name http://www.myServer.net myServer.net;
access_log /var/log/nginx/myServer_access.log;
error_log /var/log/nginx/myServer_error.log;
# certificate locations
ssl_certificate /etc/nginx/ssl/myServer.crt;
ssl_certificate_key /etc/nginx/ssl/myServer.key;
location / {
if ($http_referer ~ /nas/) {
rewrite ^(.*) /nas/$1 permanent;
}
return 404;
}
location /nas/ {
auth_basic “Restricted”;
auth_basic_user_file /etc/nginx/.htpasswd;
rewrite /nas/(.*) /$1 break;
proxy_pass http://nas_upstream;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host ‘ip.ofmy.ds’;
proxy_redirect http://ip.ofmy.ds/ /nas/;
sub_filter ‘”/’ ‘”/nas/’;
sub_filter_once off;
}
}