# URL redirect behind NGINX reverse Proxy

**URL:** <https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898>\
**Category:** 📦 Appliances (Docker, Snappy, VM, NCP, AIO)\
**Created:** [May 22, 2017, 2:33pm UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898 "2017-05-22T14:33:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bert\_Geelen](https://help.nextcloud.com/letter_avatar/bert_geelen/32/6_22734026db12803ebb3e059622ac3534.png) [@Bert\_Geelen](https://help.nextcloud.com/u/Bert_Geelen)\
**Post date:** [May 22, 2017, 2:33pm UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898/1 "2017-05-22T14:33:52Z")

</div>

Hi Guys,

I’ve setup the Nextcloud VM using the scrip provided at: [github.com/nextcloud/vm](http://github.com/nextcloud/vm)

I have an NGINX reversed proxy working to handle my SSL and load off for al my stuff.

Now i have the configuration working, but i need to remove the /nextcloud in the url.

In my config.php:  
‘overwrite.cli.url’ =\> ‘[https://cloud.mydomain.com/](https://cloud.mydomain.com/)’,

My NGINX config:

##########################################

## 

## [cloud.mydomain.com](http://cloud.mydomain.com)

## 

##########################################  
server {  
# SSL configuration  
#listen 80;  
listen 443 ssl http2;  
listen [::]:443 ssl http2;  
include /etc/nginx/snippets/strong-ssl.conf;

```
    server_name cloud.mydomain.com;

    ssl_certificate /etc/letsencrypt/live/cloud.mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/cloud.mydomain.com/privkey.pem;

    # Root location
    root /var/www/html;

    # Let's Encrypt Webroot plugin location -- allow access
    location ^~ /.well-known/acme-challenge/ {
            auth_basic off;
            autoindex on;
    }

    # Disable maximum file size
    client_max_body_size 0;

    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_set_header X-Forwarded-Proto $scheme;

            #websocket configuration
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Authorization "";
            proxy_read_timeout 86400;

            # Fix the ^ ^ It appears that your reverse proxy set up is broken" error.
            proxy_pass http://192.168.1.185;

    }

```

}

When i enter the URL [https://cloud.mydomain.com](https://cloud.mydomain.com) i ge the main status page of the VM, with the forward URLS for webmin, nextcloud etc…

How would i configure it in the way taht i go to [cloud.mydomain.com](http://cloud.mydomain.com) en get to:  
[https://cloud.mydomain.com/index.php/login](https://cloud.mydomain.com/index.php/login)  
in stead of:  
[https://cloud.mydomain.com/nextcloud/index.php/login](https://cloud.mydomain.com/nextcloud/index.php/login)

I tried to change the config php and the nginx config to [http://192.168.1.185/nextcloud](http://192.168.1.185/nextcloud) and ‘overwrite.cli.url’ =\> ‘[https://cloud.mydomain.com/nextcloud](https://cloud.mydomain.com/nextcloud)’, and any other combination. But i can’t seem to get it to work propperly.

Please help…

---

<div class="post-metadata">

**Author:** ![enoch85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/enoch85/32/49403_2.png) [@enoch85](https://help.nextcloud.com/u/enoch85)\
**Post date:** [May 23, 2017, 12:40am UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898/2 "2017-05-23T00:40:07Z")

</div>

If you run the scripts ad setup SSL with Let’s Encrypt on the backend the settings are changed and you won’t see the setup page of the VM anymore.

I run Nginx myself, and everything happens on the backend. Nginx just forwards the requests. So, forget about Nginx, run the scripts, setup Let’s Encrypt and you’re all good.

Just for refernece, here are my setup:

```auto
server {
         error_page 404 500 502 503 504 /cloud-error.html;
        location = /cloud-error.html {
                root /usr/share/nginx/html;
                internal;
        }
        real_ip_header X-Forwarded-For;
        real_ip_recursive on;

        listen 192.168.74.201:443 ssl http2;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/cloud.se/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/cloud.se/privkey.pem;
        ssl_dhparam /etc/nginx/sites-available/cloudflare_ip/cloud.se/cloud-dhparams.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:10m;
        ssl_stapling on;
        ssl_stapling_verify on;

        # Only use safe chiphers
        ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA$
        ssl_prefer_server_ciphers on;

        server_name cloud.se;
        set $upstream 192.168.20.111;

        location /.well-known {
                root /usr/share/nginx/html;
        }

## Nextcloud ##

        location / {
                proxy_pass_header Authorization;
                proxy_pass https://$upstream;
                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_http_version 1.1;
                proxy_set_header Connection "";
                proxy_buffering off;
                proxy_request_buffering off;
                client_max_body_size 0;
                proxy_read_timeout 36000s;
                proxy_redirect off;
                proxy_ssl_session_reuse off;
        }
}

server {
  listen 192.168.4.201:80;
  server_name cloud.se;
  return 301 https://cloud.se$request_uri;
}

```

---

<div class="post-metadata">

**Author:** ![Bert\_Geelen](https://help.nextcloud.com/letter_avatar/bert_geelen/32/6_22734026db12803ebb3e059622ac3534.png) [@Bert\_Geelen](https://help.nextcloud.com/u/Bert_Geelen)\
**Post date:** [May 23, 2017, 6:24am UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898/3 "2017-05-23T06:24:13Z")

</div>

Well the differance i have is that i have a separated NGINX proxy running in another machine, that is used for al lot of other items.

But, when i used your configurtion as inspiration and changed it to:

```
    location / {
            proxy_pass_header Authorization;
            proxy_pass https://192.168.1.185;
            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_http_version 1.1;
            proxy_set_header Connection "";
            proxy_buffering off;
            proxy_request_buffering off;
            client_max_body_size 0;
            proxy_read_timeout 36000s;
            proxy_redirect off;
            proxy_ssl_session_reuse off;
    }

```

All sseemed to work perfectly!

Thanx!

---

<div class="post-metadata">

**Author:** ![enoch85](https://help.nextcloud.com/user_avatar/help.nextcloud.com/enoch85/32/49403_2.png) [@enoch85](https://help.nextcloud.com/u/enoch85)\
**Post date:** [May 23, 2017, 12:09pm UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898/4 "2017-05-23T12:09:32Z")

</div>

> [@Bert\_Geelen](#):
>
> Well the differance i have is that i have a separated NGINX proxy

Just for the record, I also run a separate Nginx proxy as it handles all my servers. 😉

Glad it worked out! 🙂

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 2, 2024, 8:42am UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898/5 "2024-12-02T08:42:11Z")

</div>



---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 9, 2024, 1:24pm UTC](https://help.nextcloud.com/t/url-redirect-behind-nginx-reverse-proxy/12898/6 "2024-12-09T13:24:35Z")

</div>


