lilp
lilp

Reputation: 3

Nginx reverseproxy and LXC

I install nextcloud with Turnkey LXC template on Proxmox. I use Nginx as Reverseproxy on another LXC. My LXC Nextcloud is on 192.168.1.46 and my LXC Nginx on 192.168.1.38. I have a free account on No-ip for dynamic dns for access like : XxX.Xxx.Xxx

When I go to my Nextcloud on LAN is OK on IP LAN, but when I try by dynamic DNS with “XXX.XXX/nextcloud” I redirected to LAN IP, and it’s inaccessible. Here it's my nginx conf file :

    upstream plex_backend {
    server 192.168.1.30:32400;
    keepalive 32;
    }


server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name Xxx.xxx.xxx;
    ssl_certificate /etc/letsencrypt/live/Xxx.xxx.xxx/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/Xxx.xxx.xxx/privkey.pem; # managed by Certbot
  
  location / {
    proxy_pass http://192.168.1.41;
    }
 
    location /nextcloud {
    proxy_pass http://192.168.1.46/nextcloud;
    }

}

 
server {
    if ($host = Xxx.xxx.xxx) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


   listen 80 default_server;
   listen [::]:80;
   server_name Xxx.xxx.xxx;
   proxy_buffering off;
   add_header X-Frame-Options SAMEORIGIN;
   add_header X-Content-Type-Options nosniff;
   add_header X-XSS-Protection "1; mode=block";
   add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
   add_header Referrer-Policy strict-origin;
   real_ip_header X-Forwarded-For;
   rewrite ^(.*) https://Xxx.xxx.xxx$1 permanent;

  
   location / {
    rewrite ^(.*) https://Xxx.xxx.xxx$1 permanent;
    proxy_set_header X-Forwarded-Ssl on;
    }

   location /nextcloud {
    proxy_pass http://192.168.46/nextcloud;
    }
}

I don't understand why.

Thanks

Upvotes: 0

Views: 445

Answers (1)

inosak
inosak

Reputation: 41

location /nextcloud {
proxy_pass http://192.168.46/nextcloud;
}

You should use "https" or NextCloud will try to redirect (it depends on NC configuration tbh):

location /nextcloud {
proxy_pass https://192.168.46/nextcloud;
}

Upvotes: 0

Related Questions