'I get 404 when nginx reverse proxy. nextcloud

I am having a very difficult time.

Below is the configuration that originally worked in Apache.

<VirtualHost *:443>
ServerName  example.com

SSLEngine on
SSLCertificateKeyFile [[[PIRVKEY]]]
SSLCertificateFile [[[CERT]]]
SSLCACertificateFile [[[FULLCHAIN]]]

<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>


<Proxy *>
 Order deny,allow
 Allow from all
</proxy>

SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

ProxyPass / http://example.com:10000/ nocanon
ProxyPassReverse / http://example.com:10000/

RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
<VirtualHost *:80>
    ServerName example.com
    Redirect / https://example.com/
</VirtualHost>

It has been processed as below. container(apache, cloud.example.com)>> container(nextcloud, example.com:10000)

It was a virtual host consisting of example.com and cloud.example.com, in the form of a reverse proxy.

Recently I cleared apache and created that proxy with nginx. Below is the corresponding configuration file.

server {
server_name cloud.example.com;
location / {
  #root /usr/share/nginx/html/cloud.example.com;
  #index index.html;

  proxy_redirect     default;
  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_pass http://example.com:10000;
  try_files $uri $uri/ =404;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/cloud.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cloud.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot 
}


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


server_name cloud.example.com;
listen 80;
return 404; # managed by Certbot

}

Unfortunately, if you go to cloud.example.com you will be directed to a 404 page. For reference, example.com:10000 is working normally.

Both apache and nginx used certbot.

Does anyone know how to solve it? Thanks for reading.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source