Reverse proxy issue with Nginx, showing 404 error

I’m running nextcloud 12 on apache at port 8888 with nginx as reverse proxy, the below configuration is giving 404 when i hit nextcloud from outside via nginx, but it working fine on internal network hosted on apache.

below are the configuration details.

pi@raspberrypi:~ $ nginx -v
nginx version: nginx/1.10.3
pi@raspberrypi:~ $ apache2 -v
Server version: Apache/2.4.25 (Raspbian)
Server built:   2017-09-19T18:58:57
pi@raspberrypi:~ $ php -v
PHP 7.0.27-0+deb9u1 (cli) (built: Jan  5 2018 13:51:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.27-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies
pi@raspberrypi:~ $

Internal URL (directly hits apache) :
Outside URL (via nginx reverse proxy) :

Not Found
The requested URL /nextcloud/nextcloud/index.php/login was not found on this server.

Apache/2.4.25 (Raspbian) Server at Port 80


pi@raspberrypi:~ $ sudo cat /var/www/html/nextcloud/config/config.php 
$CONFIG = array (
  'instanceid' => 'oc0okf3ebww7',
  'passwordsalt' => '@@@@@@@@@@',
  'secret' => '@@@@@@@@@@@@@@@@@@@@@@@',
  'trusted_domains' => 
  array (
    0 => '',
    1 => '',
    2 => '',
  'datadirectory' => '/var/www/html/nextcloud/data',
  'overwrite.cli.url' => '',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextclouduser',
  'dbpassword' => 'nextcloudpassword',
  'logtimezone' => 'UTC',
  'installed' => true,

Nginx configuration is mentioned below.

server {
        listen 443 ssl;
        access_log /var/log/nginx/;
        error_log /var/log/nginx/;
        client_max_body_size 0;
        underscores_in_headers on;
        ssl on;
        ssl_certificate_key /home/pi/website-ssl-cert/private.key;
        ssl_certificate /home/pi/website-ssl-cert/certificate.crt;
        ssl_stapling on;
        ssl_stapling_verify on;
        location / {
            proxy_pass_header Authorization;
            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;

Thanks for your help in advance.

I´m not fluent in nginx, so i may miss some obvious points, but the following error Message

has the nextcloud 2 times in there. What is strange, that you explicitly told the Reverseproxy to use 8888, yet the error says port 80. Is this error from the Apache error log or from your browser?

May you please post your apache config too?

Could be that you dont need to specify the ports under
'overwrite.cli.url' and

it may even be, that it breaks something, i dont know, since i never tried it.

Thanks @Ascendancer for your support, this thread can be mark as closed.

Below is the config i’ve used in ngnix and it is working as expected.

server { listen 443 ssl; server_name; ssl on; ssl_certificate_key /website-ssl-cert/private.key; ssl_certificate /website-ssl-cert/certificate.crt; location /nextcloud/ { proxy_pass; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location / { proxy_pass; } }

Great to hear :slight_smile:
What was the issue then? Cant figure it our from you post. Just beeing curious.

Next time watch out and do not post the 'passwordsalt' and 'secret'. They are important for the security of your server!

@casKd-dev : Thanks for heads-up, appreciate it :slight_smile:

1 Like

Nginx was not able to handle URL with anything after the primary domain, so it was giving error

So i had add an directive to handle this issue,

Hope this will quench your curiosity. :vulcan_salute: