I am using a nginx reverse proxy server. Behind the reverse proxy are 3 apache servers on 3 IP addresses
apache 2 and apache 3 work great.
This is the nginx configuration for apache2
/etc/nginx/sites-available/www.domain1.tld
This is the apache2 configuration
/etc/apache2/sites-available/www.domain1.tld.conf
I created a similar configuration for apache1
/etc/nginx/sites-available/www.domain2.tld
/etc/apache2/sites-available/www.domai2.tld.conf
When I paste an address domain1.com into a web browser, I see the correct content. When I paste an address domain2.com into a web browser, I see
Nginx will probably forwarded it to the correct server, but it will not forwarded it to a specific vhost.
I think that apache2 and apache3 work correctly because they contain only 1 vhost. Apache1 contains 4 vhosts and therefore it does not work.
I tried to set the proxy_pass directive to the root directory
However, nothing has changed.
Can anyone advise me why a reverse proxy does not route specific hosting requests?
I'm sorry for my english
Code:
apache1 - 192.168.1.101 (4x vhost)
apache2 - 192.168.1.106 (1x vhost)
apache3 - 192.168.1.107 (1x vhost)
nginx - 192.168.1.105
This is the nginx configuration for apache2
/etc/nginx/sites-available/www.domain1.tld
Code:
server {
listen 80;
server_name domain1.tld;
return 301 http://www.domain1.tld$request_uri;
}
server {
listen 80;
server_name www.domain1.tld;
location / {
proxy_pass http://192.168.1.106;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
This is the apache2 configuration
/etc/apache2/sites-available/www.domain1.tld.conf
Code:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain1.tld
ServerAlias www.domain1.tld
DocumentRoot /var/www/html/www.domain1.tld/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I created a similar configuration for apache1
/etc/nginx/sites-available/www.domain2.tld
Code:
server {
listen 80;
server_name domain2.tld;
return 301 http://www.domain2.tld$request_uri;
}
server {
listen 80;
server_name www.domain2.tld;
location / {
proxy_pass http://192.168.1.101;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
/etc/apache2/sites-available/www.domai2.tld.conf
Code:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain2.tld
ServerAlias www.domain2.tld
DocumentRoot /var/www/html/www.domain2.tld/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When I paste an address domain1.com into a web browser, I see the correct content. When I paste an address domain2.com into a web browser, I see
Code:
Not Found
The requested URL was not found on this server.
Apache/2.4.25 (Debian) Server at www.domain2.tld Port 80
I think that apache2 and apache3 work correctly because they contain only 1 vhost. Apache1 contains 4 vhosts and therefore it does not work.
I tried to set the proxy_pass directive to the root directory
Code:
proxy_pass http://192.168.1.101/www.domain2.tld;
Can anyone advise me why a reverse proxy does not route specific hosting requests?
I'm sorry for my english
Last edited: