mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-04-26 01:45:54 +03:00
[GH-ISSUE #928] nginx-proxy-manager + nextcloud:fpm = 502 Bad Gateway #787
Labels
No labels
awaiting feedback
bug
cannot reproduce
dns provider request
duplicate
enhancement
enhancement
enhancement
good first issue
help wanted
invalid
need more info
no certbot plugin available
product-support
pull-request
question
stale
troll
upstream issue
v2
v2
v2
v3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-proxy-manager-NginxProxyManager#787
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @talesam on GitHub (Mar 6, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/928
I'm using two separate docker-compose files, some with npm and one with nextcloud. I get the npm network to use in the nextcloud, but I have an error when accessing the 502 Bad Gateway nextcloud.
Below my nextcloud docker-compose
My conteiners

Configuration SSL


@sgb999 commented on GitHub (Mar 7, 2021):
i posted the same issue, there is a communication error somewhere between the database and the app, no idea how to fix, must be a bug in the program
@talesam commented on GitHub (Mar 7, 2021):
Let's see if anyone finds an answer, I put it well specified.
If using the nextcloud: latest image works, but this image has apache built in, it doesn't make sense, it doesn't!
@sgb999 commented on GitHub (Mar 7, 2021):
I think you're confused. It has nothing to do with the image that you are proxying to at all. Its an issue when the app talks to the database, it happens for any docker image you proxy to even if apache is not involved.
@talesam commented on GitHub (Mar 7, 2021):
It's not a problem with the bank, it works for me if I change where nextlcoud is: fpm to nextcloud: latest, everything will work fine, but I don't want to use this image, as it comes with built-in apache.
Again, if I use the "nextcloud" image other than with ngnix, it works perfectly.
You can test this compose docker that will work:
db.env
@l4rm4nd commented on GitHub (Mar 26, 2021):
Sometimes the HTTP/2 support can break some stuff. Try disabling it, might help .. might not.
@talesam commented on GitHub (Mar 26, 2021):
That's not it, I had already tested it.
@talesam commented on GitHub (Apr 3, 2021):
Nobody knows if it is possible to run the
nextcloud:fpmimage with nginx proxy manager?It should work, since there is a web server running at npm, right?
How would it be to run npm with this docker-compose? (https://hub.docker.com/_/nextcloud)
@aventustudio commented on GitHub (Apr 17, 2021):
I was able to fix similar problems with a custom nextcloud config: https://docs.nextcloud.com/server/21/admin_manual/configuration_server/reverse_proxy_configuration.html#
You'll find examples in config.sample.php.
config.php
I also added this in proxy manager (Edit Proxy Host/Advanced):
Not sure if it is necessary, I haven't testet cal and carddav yet.
@talesam commented on GitHub (Apr 17, 2021):
For version 21 it is, for version 20 it is not.
@gil00pita commented on GitHub (May 6, 2021):
Go to Advanced and try to add this:
On my machine works, and don't forget to add server IP and port not the IP of the container.
@talesam commented on GitHub (May 6, 2021):
Can I take a look at your docker-compose?
@huangwb8 commented on GitHub (Apr 25, 2022):
@gil00pita
I use your config and got a
502 Bad Gateway. May I just have a look at your docker-compose.yml?@Hadatko commented on GitHub (Aug 18, 2023):
Hello guys, just quickly i can describe how i managed nextcloud-fpm working. It took me more time for such tiny change.
The biggest issue was that i didn't realized that my npm saw nextcloud folder as /var/www/nextcloud and nextcloud saw its folder in /var/www/html/nextcloud.
Settings are relly easy:
volume for nextcloud container:
- /var/www/nextcloud:/var/www/html:777 # so if you change it to /var/www/html:/var/www/html you will have 1 error less. But it can be fixed easily
volume i had for npm:
- /var/www:/var/www
Explanation image bellow -> Port is random free number diferent to nginx default. Just choose it here. I added hostname to nginx called nginx, but you can use nginx ip.

Generate certificates

Now save to get certificates generated (if you have your own you can skip this step). If not you need backed up ssl_certificate and ssl_certificate_key lines in your config which is afaik hidden in gui. You can attach in container for nginx and go /data/nginx/proxy_host/ and here choose correct config (In config you will find your url from first image) and copy somewhere these two values.
Into advanced tab you need copy everything from official nextcloud webpage (https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html) what is inside brackets (only inside) server {} for ssl (443 port) without server {} (this adavanced data are saved inside server{}).

Modifications in advance tab:
root-> in my case unmodified as nginx see nextcloud in /var/www/nextcloudssl_certificateandssl_certificate_keywith you certificates (for example if you backed lines up based on steps above)fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;-> as nextcloud container store nextcloud/* in /var/www/htmladd_header Cache-Control "public, max-age=15778463";-> Didn't know how to correctly replace asset_immutable (i just made it working and writing these lines) so i removed it.fastcgi_pass nextcloud2:9000;-> You can see i am not calling handler but directly server:port. In my case nextcloud container hostname is nextcloud2, but you can use ip:port.I think that is all. Do not forget have nginx and nextcloud on same network. In that case you don't need expose nextcloud ports. Or expose ports and then you can use system ip. (i think container ip can be changed on reboot, so i am using hostname rather and not exposing ports)
Troubleshooting:

Red dot means wrong config. Sometimes i could edit and save. Sometimes i had to restart nginx after changes (e.g. modifying nginx configuration as described above in container directly. These changes are not permanent and you will not see them in gui. So once you will do some changes and you are ok with them you need save them using gui).
Always read logs from both nginx and nextcloud container.
To get rid of red dot i suggest comment code untill it will pass and then uncomment and figure out which line is causing error and fix (syntax/logix/semantic). If you will have error during saving, you need edit file manually and restart nginx.
172.19.0.5 - 18/Aug/2023:21:21:14 +0000 "GET /index.php" 200 -> likely wrong set of SCRIPT_FILENAME
Error 404 when accesing on web -> could be wrong set of root
@github-actions[bot] commented on GitHub (Mar 17, 2024):
Issue is now considered stale. If you want to keep it open, please comment 👍
@github-actions[bot] commented on GitHub (Apr 28, 2025):
Issue was closed due to inactivity.