Error: nginx as reverse proxy for Apache

Discussion in 'General' started by effoo, Sep 10, 2018.

  1. effoo

    effoo New Member

    Hello everbody,

    I have a working Nextcloud running on my local Apache which I want to access through a domain, I setup in ISPConfig which is running on nginx.
    But all I get is a 500 Internal Server Error from nginx.

    Apache is running on port 8082, configured in /etc/apache2/ports.conf
    Code:
    Listen 8082
    
    #<IfModule ssl_module>
    #       Listen 443
    #</IfModule>
    
    #<IfModule mod_gnutls.c>
    #       Listen 443
    #</IfModule>
    Confirmed by netstat:
    Code:
    tcp6       0      0 :::8082                 :::*                    LISTEN      15340/apache2
    Apache's only enabled site:
    Code:
    <VirtualHost 127.0.0.1:8082>
            ServerAdmin     webmaster@localhost
            DocumentRoot    /var/www/html/nextcloud
    
            ErrorLog        ${APACHE_LOG_DIR}/nextcloud_error.log
            CustomLog       ${APACHE_LOG_DIR}/nextcloud_access.log combined
    
    #        <Directory /var/www/http/nextcloud/>
    #                Options         -Indexes +FollowSymlinks
    #                AllowOverride   All
    #                <IfModule mod_dav.c>
    #                                Dav off
    #                </IfModule>
    #                SetEnv          HOME /var/www/http/nextcloud
    #                SetEnv          HTTP_HOME /var/www/http/nextcloud
    #                Satisfy         Any
    #        </Directory>
    # this is commented out because I dunno if that breaks things
            <Directory /var/opt/nextcloud-data/>
                    Require         all denied
            </Directory>
    </VirtualHost>
    nginx vhost file from ISPConfig (modified by me):
    Code:
    server {
            listen *:80;
            listen *:443 ssl;
                    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_certificate /var/www/clients/client1/web5/ssl/...
            ssl_certificate_key /var/www/clients/client1/web5/ssl/...
    
            server_name subdomain.domain.tld;
    
            root    /var/www/html/nextcloud;
            #root   /var/www/subdomain.domain.tld/web/;
            # this was the original ISPConfig root path
    
            index index.html index.htm index.php index.cgi index.pl index.xhtml;
    
            location / {
                proxy_pass http://localhost:8082;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-Proto $scheme;
            }
    
            error_page 400 /error/400.html;
            error_page 401 /error/401.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 405 /error/405.html;
            error_page 500 /error/500.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            recursive_error_pages on;
            location = /error/400.html {
    
                internal;
            }
            location = /error/401.html {
    
                internal;
            }
            location = /error/403.html {
    
                internal;
            }
            location = /error/404.html {
    
                internal;
            }
            location = /error/405.html {
    
                internal;
            }
            location = /error/500.html {
    
                internal;
            }
            location = /error/502.html {
    
                internal;
            }
            location = /error/503.html {
    
                internal;
            }
    
            error_log /var/log/ispconfig/httpd/subdomain.domain.tld/...
            access_log /var/log/ispconfig/httpd/subdomain.domain.tld/...
    
            location ~ /\. {
                            deny all;
            }
    
            location ^~ /.well-known/acme-challenge/ {
                            access_log off;
                            log_not_found off;
                            root /usr/local/ispconfig/interface/acme/;
                            autoindex off;
                            index index.html;
                            try_files $uri $uri/ =404;
            }
    
            location = /favicon.ico {
                log_not_found off;
                access_log off;
                expires max;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            }
    
            location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
            }
    
            location /stats/ {
    
                index index.html index.php;
                auth_basic "Members Only";
                auth_basic_user_file /var/www/clients/client1/web5/web/...
            }
    
            location ^~ /awstats-icon {
                alias /usr/share/awstats/icon;
            }
    
            location ~ \.php$ {
                try_files /abc.htm @php;
            }
    
    
            location @php {
                deny all;
            }
    
    }
    Maybe I'm missing some settings for the domain inside of ISPConfig?
    I followed a lot of setups on how to reverse proxy from nginx to Apache by now but I still can't figure out why this is not happening.

    Edit: If I set PHP in ISPConfig to PHP-FPM, I get a 404 error "The requested URL was not found on this server.". Before it was deactivated.

    I am grateful for any help. Thank you!
     
    Last edited: Sep 10, 2018
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Post the error message that corresponds to the 500 error from error.log file of the website.
     
  3. effoo

    effoo New Member

    I'm getting 403s now...so something changed.
    Error.log
    Code:
    2018/09/11 20:38:28 [error] 18084#18084: *2363 access forbidden by rule, client: ip.ip.ip.ip, server: subdomain.domain.tld, request: "GET /status.php HTTP/1.1", host: "subdomain.domain.tld"
    Access.log
    Code:
    ip.ip.ip.ip - name [11/Sep/2018:20:40:36 +0200] "GET /status.php HTTP/1.1" 403 872 "-" "Mozilla/5.0 (Macintosh) mirall/2.3.3 (build 84) (Nextcloud)"
     

Share This Page