Proxy webapps nginx

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
AlojzMustafa
Posts: 1
Joined: Wed Nov 27, 2019 3:45 pm

Proxy webapps nginx

Post by AlojzMustafa »

Hello,

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.
User avatar
MichaIng
Site Admin
Posts: 2336
Joined: Sat Nov 18, 2017 6:21 pm

Re: Proxy webapps nginx

Post by MichaIng »

Check out: https://docs.nginx.com/nginx/admin-guid ... rse-proxy/
You could use our drop-in directory to apply this as a separate config file which can then be easily adjusted/removed independantly.

Code: Select all

cat << _EOF_ > /etc/nginx/sites-dietpi/portrainer.conf
location ^~ /portainer {
	proxy_pass http://localhost:9000;
}
_EOF_
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: http://nginx.org/en/docs/http/ngx_http_ ... y_redirect
Post Reply