nginx reverse proxy

gusto1 nginx-forum at forum.nginx.org
Wed Mar 31 14:19:08 UTC 2021


I'm newbie to nginx

I have an apache server in lxc
192.168.1.10 (3x vhost/domain)

Each vhost is configured as follows and works perfectly

----------
<VirtualHost *:80>
        DocumentRoot /var/www/www.domain1.ddns.com
        ServerName domain1.ddns.com
        ServerAlias www.domain1.ddns.com
        ServerAdmin webmaster at domain1.ddns.com
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^domain1\.ddns\.com$ [NC]
        RewriteRule ^(.*)$ http://www.domain1.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.domain1.ddns.com
        ServerName domain1.ddns.com
        ServerAlias www.domain1.ddns.com
        ServerAdmin webmaster at domain1.ddns.com
  <IfModule mod_ssl.c>
        SSLEngine on
        SSLCertificateKeyFile
/etc/letsencrypt/live/domain1.ddns.com/privkey.pem
        SSLCertificateFile /etc/letsencrypt/live/domain1.ddns.com/cert.pem
        SSLCertificateChainFile
/etc/letsencrypt/live/domain1.ddns.com/chain.pem
#       SSLCertificateChainFile
/etc/letsencrypt/live/domain1.ddns.com/fullchain.pem
  </IfModule>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^domain1\.ddns\.com$ [NC]
        RewriteRule ^(.*)$ https://www.domain1.ddns.com$1 [R=301,NE,L]
</VirtualHost>
-----------

All my domains are visible from the internet because I have forward ports
80/443 on IP 192.168.1.10

Now I will build another apache server in lxc
192.168.1.11 (3x vhost/domain)
For vhosts I want to use a similar configuration as on the first apache.
I don't want to change the configuration of apache vhosts.
Because it is not possible to make forward ports to 2 local IP addresses, I
need to build a reverse proxy.

Today I installed nginx in lxc
192.168.1.12
How should I configure nginx?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,291114,291114#msg-291114



More information about the nginx mailing list