I wrote an article before saying that I Migrate Plesk to Hestia After a period of use,Except for missing some features,Overall it is very stable and practical.。Recently I've been tinkering with some Docker applications,Just found out Hestia not like Please That way you can control and manage docker directly from the UI,of course,due to Hestia The lightweight design architecture itself,We can still easily make it implement Docker App reverse generation,Of course,It really can't be managed Docker service,You have to log in to the server yourself and run the command to start it。
Docker App
I won’t go into details here.,Let’s assume that an App is opened in 8081 port,have been able to pass 127.0.0.1:8081 get on http access。
Speak the truth,In fact, this solution supports any application that requires local reverse generation.,such as NodeJS ,Essentially we are for Hestia. Nginx Template adds a set of anti-generation templates and then loads it。
Add Nginx configuration
Hestia's Nginx places website configuration here /etc/nginx/conf.d/domains/plex.mydomain.with.conf But you can't modify it directly,Because this will be overwritten by the template。of course,You also cannot modify existing templates to change configurations.,On the one hand, this is because all sites will be changed.,The flip side is that once Hestia is updated,The template is overwritten。So we need to create a separate set of templates,Since we want to customize the port to 8081 Or the port of other local applications,So you need to create a template for each application。
Create Hestia Nginx configuration template
The template is located in /usr/local/hestia/data/templates/web/nginx Directory,divided into .tpl and .stpl Two kinds,Usually two files with one name,These two suffixes correspond to http and https configuration,We can directly copy the default default.tpl default.stpl file as start。turn on tpl file,You will find that it is basically the configuration file of Nginx,It's just that the content inside has been replaced by %Xxx.% dynamic content like this,There is only one thing we need to change,Just replace %web_port% for our 8081 instead of the default Apache port。
Similarly,turn on stpl file,But this time it's %web_ssl_port% Since we do not need to set up ssl on the intranet,So change it to the same port 8081 ,But this time it's not over yet,We need to change the upstream address inside from https To http ,Because our docker app does not need to support ssl,We will eventually create the site in Hestia and add ssl support。
note,In these two files,There are two places to edit respectively,one is location / below proxy_pass Field,the other is location @fallback ,Both fields must be modified。
Here I give stpl Modified example of:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
location / { proxy_pass http://%ip%:8081; location ~* ^.+\.(%proxy_extensions%)$ { try_files $uri @fallback; root %sdocroot%; access_log /var/log/%web_system%/domains/%domain%.log combined; access_log /var/log/%web_system%/domains/%domain%.bytes bytes; expires max; } } location @fallback { proxy_pass http://%ip%:8081; } |
Site configuration
After the template is created, it can be configured in Hestia。After doing your domain name resolution,Create the corresponding site directly in Hestia,Then enable https and other configurations normally in the settings.。From now on,This is a normal empty site,Here comes the point,The interface set in the site,Click on "Advanced Options",Here you can switch templates for Nginx,We open its drop-down menu,At this point you should be able to see the newly created template,Choose,Just apply。
References
- https://forum.hestiacp.com/t/nginx-reverse-proxy-for-docker-app/1427
- https://hestiacp.com/docs/server-administration/web-templates.html
Original article written by LogStudio:R0uter's Blog » Hestia CP with Docker app
Reproduced Please keep the source and description link:https://www.logcg.com/archives/3871.html