Welcome! Log In Create A New Profile

Advanced

How to config NGINX such that I can call https://<MY_DOMAIN>:<MY_PORT>/<URI>/

Posted by vildnex 
How to config NGINX such that I can call https://<MY_DOMAIN>:<MY_PORT>/<URI>/
October 02, 2023 12:44PM
**What I am trying to DO:**

I have a QNAP NAS on which I am trying to set up my NGINX via docker such that I will be able to add multiple services on my home server.
What I am trying to do now is to set the NGINX such that when I call the

`https://<MY_DOMAIN>:<MY_PORT>/nas` to redirect all the calls to http://192.168.0.98:8085 which is my local IP and local port from my QNAP.

**The problem:**

What is happening right now is that instead of redirect all the calls from `https://<MY_DOMAIN>:<MY_PORT>/nas` to `http://192.168.0.98:8085` they are instead redirected from `https://<MY_DOMAIN>:<MY_PORT>/nas` to `https://<MY_DOMAIN>:<MY_PORT>` and then I will get a `404 not found` error on `https://<MY_DOMAIN>:<MY_PORT>`

**The configuration that is working at the moment, but only with `/` instead of `/nas/`**

location / {
proxy_pass http://192.168.0.98:8085/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

**The PROBLEM:**

At the moment when I am trying to add the `/nas/` part this is not going to work and I will always be redirected from `https://<MY_DOMAIN>:<MY_PORT>/nas` to `https://<MY_DOMAIN>:<MY_PORT>` and then I will get a `404 not found` error on `https://<MY_DOMAIN>:<MY_PORT>`

**Different types of combinations that I've tried and non a single one of them worked.**


location ~ ^/nas(/.*)$ {
proxy_pass http://192.168.0.98:8085$1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location ^~ /nas/ {
rewrite ^/nas(/.*)$ $1 break;
proxy_pass http://192.168.0.98:8085;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location /nas {
proxy_pass http://192.168.0.98:8085;
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_redirect off;
proxy_intercept_errors on;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location ^~ /nas {
rewrite ^/nas(/.*)$ $1 break;
proxy_pass http://192.168.0.98:8085;
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_redirect off;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location /nas/ {
proxy_pass http://192.168.0.98:8085/;
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_redirect off;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location /nas/ {
proxy_pass http://192.168.0.98:8085;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location ^~ /nas {
rewrite ^/nas(/.*)$ $1 break;
proxy_pass http://192.168.0.98:8085;
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_redirect off;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location ~ ^/nas(/.*)$ {
proxy_pass http://192.168.0.98:8085$1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

location ^~ /nas/ {
proxy_pass http://192.168.0.98:8085/;
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_redirect off;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 188
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready