Article 5G3HC nginx reverse proxy

nginx reverse proxy

by
gusto1
from LinuxQuestions.org on (#5G3HC)
I have a small LAN and one public IPv4 address.
I currently have (in proxmox) one LXC installed, where LAMP is running (IP 192.168.1.101).
There are 4 vhosts configured in apache.

web1.ddns.info
web2.ddns.com
web3.ddns.org

Each vhost is configured as follows. Let's take it as an example, web2.ddns.com

Code:<VirtualHost *:80>
DocumentRoot /var/www/www.web2.ddns.com
ServerName web2.ddns.com
ServerAlias www.web2.ddns.com
ServerAdmin webmaster@web2.ddns.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^web2\.ddns\.com$ [NC]
RewriteRule ^(.*)$ http://www.web2.ddns.com$1 [R=301,NE,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
</VirtualHost>

<VirtualHost *:443>
DocumentRoot /var/www/www.web2.ddns.com
ServerName web2.ddns.com
ServerAlias www.web2.ddns.com
ServerAdmin webmaster@web2.ddns.com
<IfModule mod_ssl.c>
SSLEngine on
SSLCertificateKeyFile /etc/letsencrypt/live/web2.ddns.com/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/web2.ddns.com/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/web2.ddns.com/chain.pem
# SSLCertificateChainFile /etc/letsencrypt/live/web2.ddns.com/fullchain.pem
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^web2\.ddns\.com$ [NC]
RewriteRule ^(.*)$ https://www.web2.ddns.com$1 [R=301,NE,L]
</VirtualHost>With the previous configuration, it works as follows and it was my main requirement.
If the client enters one of the options in the web browser.

web2.ddns.com
www.web2.ddns.com
http://web2.ddns.com
http://www.web2.ddns.com
https://web2.ddns.com
https://www.web2.ddns.com

will always be redirected to

https://www.web2.ddns.com

All this works great including letsencrypt autoupdate.
Now I'm going to build a next LAMP in the new LXC (IP 192.168.1.104). There will also be 3 vhosts.
I want the hosts to behave the same as on the first LAMP (IP 192.168.1.101).
I wrote that I only have one public ipv4 address. Therefore, I need to forward all requests to web servers through a reverse proxy.
Today I installed another LXC with nginx (IP 192.168.1.105)-
Now I need to configure nginx as a reverse proxy. I will probably have to change the config for vhosts as well.
I googled a lot but I didn't find a tutorial on how to do it.latest?d=yIl2AUoC8zA latest?i=34LAuhszFaI:M0WLddKDHSg:F7zBnMy latest?i=34LAuhszFaI:M0WLddKDHSg:V_sGLiP latest?d=qj6IDK7rITs latest?i=34LAuhszFaI:M0WLddKDHSg:gIN9vFw34LAuhszFaI
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments