Proxy webapps nginx


I am running DietPi with Nextcloud. Nextcloud is available as ip_adress/nextcloud.

Also I would like to use Portrainer in Docker (as image). How could I set up Portrainer available as ip_address/portrainer instead of ip_address:9000.

Using nginx as webserver.

Could someone help me?

BTW: Thank you for great work.

Check out:
You could use our drop-in directory to apply this as a separate config file which can then be easily adjusted/removed independantly.

cat << _EOF_ > /etc/nginx/sites-dietpi/portrainer.conf
location ^~ /portainer {
	proxy_pass http://localhost:9000;
systemctl reload nginx

The ^~ in location directive btw means that Nginx shall stop searching for other matching location directives, which is in most cases useful when having web application specific locations and some more generic locations later on (something like .*.php to apply directives to PHP files, which would be covered in this case Docker-internally already.)

If you want to use HTTPS, assure that /etc/nginx/sites-dietpi is included from the 443/HTTPS vhost (default when enabled via dietpi-letsencrypt) and then adjust the above to proxy to https://…
There is also a proxy_redirect redective, which can be used to proxy from http to https, if your other website(s) should be accessible via HTTP, but portainer via HTTPS: