Nextcloud Nginx Reverse-Proxy to Apache connect

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): newest
Operating system and version (eg, Ubuntu 20.04): ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): apache newest
PHP version (eg, 7.4): 7.4

install with the setup.php site from the website

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N):

Hello :slight_smile:

I have a Proxmox server with a NGINX server. As VPS I have a Nextcloud. I can login via IP.

My Proxmox is avaible via a Domain. I want the Nginx as reverse Proxy to my cloud and other services. I have this code in proxmox.conf

upstream proxmox {
    server proxmox.domain.com;
    
}
 
server {
    listen 80 default_server;
    rewrite ^(.*) https://$host$1 permanent;
}
 
server {
    listen 443;
    server_name proxmox.domain.com;
    ssl on;
    ssl_certificate /etc/ca-certificates/crt.crt;
    ssl_certificate_key /etc/ca-certificates/key.key;
    proxy_redirect off;
    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade"; 
        proxy_pass https://localhost:8006;
	proxy_buffering off;
	client_max_body_size 0;
	proxy_connect_timeout  3600s;
        proxy_read_timeout  3600s;
        proxy_send_timeout  3600s;
        send_timeout  3600s;
    }
}

upstream php {
    server nextcloud.domain.com;
}
server {

    listen 443;
    server_name nextcloud.domain.com;
    ssl on;
    ssl_certificate /etc/ca-certificates/crt.crt;
    ssl_certificate_key /etc/ca-certificates/key.key;
    proxy_redirect off;
    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade"; 
        proxy_pass https://192.168.178.139:443;
	proxy_buffering off;
	client_max_body_size 0;
	proxy_connect_timeout  3600s;
        proxy_read_timeout  3600s;
        proxy_send_timeout  3600s;
        send_timeout  3600s;
    }
}

Here are the Ports of the Apache

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80

<IfModule ssl_module>
	Listen 443
</IfModule>

<IfModule mod_gnutls.c>
	Listen 443
</IfModule>


NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Here ist the nextcloud.conf of the Apache:

<VirtualHost *:80>
 DocumentRoot "/var/www/html/nextcloud"
 ServerName nextcloud.domain.com

Redirect permanent / https://nextcloud.domain.com
Alias nextcloud.domain.com /var/www/html/nextcloud
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/nextcloud/>
 Options +FollowSymlinks
 AllowOverride All

 <IfModule mod_dav.c>
 Dav off
 </IfModule>

 SetEnv HOME /var/www/htm/nextcloud
 SetEnv HTTP_HOME /var/www/html/nextcloud
 Satisfy Any

</Directory>

</VirtualHost>

I have change the Ports to 80/443 and I get everytime Bad Gateway 502

Here is the error Log of the Nginx server. The errorlog if Apache is empty.

2021/04/10 14:41:47 [error] 2684#2684: *197 connect() failed (111: Connection refused) while connecting to upstream, client: 91.184.168.251, server: nextcloud.domain.com, request: "GET / HTTP/1.1", upstream: "https://192.168.178.139:443/", host: "nextcloud.domain.com"

What I is wrong with this configuration? I tried a couple of options out of the Internet, but nothing works :confused:

I think the Apache refused it for security reason. But I don’t know where I can config this, to get the Server run behind the reverse Proxy.

Can anybody help me? :slight_smile: