How to configure nginx in host for nextcloud:fpm container?

I running a nextcloud:fpm container in docker

docker run -d -v /nextcloud:/var/www/html nextcloud:fpm

the port 9000 was not opened after container initialization finished.

If I map container port 9000 to host

docker run -d -v /nextcloud:/var/www/html -p 9000:9000 nextcloud:fpm

and proxy port 80 to port 9000, nextcloud’s web page can be opened, but without style

browser error message

Refused to execute script from ‘’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from ‘http://localhost/core/js/dist/main.js?v=ba222ded25d957b900c03bef914333cd’ because its MIME type (‘text/html’) is not executable, and strict MIME type checking is enabled.

How to config nginx(host) for fpm container?

sure that you want to run nginx on the host and not in a container?

you’ll find a lot of examples here:

or without letsencrypt certificate:

Thank you!

My host is a VM with a small amount of memory, and I deployed a web server nginx on my host before installing nextcloud, so I wanted to use the host’s nginx directly instead of adding an nginx container.

Also, using the nextcloud:apache container might be a better choice than adding nginx containers.

ok. the nginx conf should be basically the same. i guess. you only have to change the server name app the upstream php-handler section to localhost.

and to my understanding an nginx container is more or less the same like a nginx process on the host.

Thank you for your help.

I’ve tried this, and as I said on #1, the nextcloud web page that opens will have no style.

the php-fpm can’t handle static web content. (e.g. css files)

so you must not proxy port 9000.

you must setup a web server that handles everything (html, css, …) except php. all request for php are redirected to the php-fpm container. that’s defined in the upstream section.