0

I'm having a problem with my apache setup.

I'm using a Proxmox server with multiple virtual machines and only one public IP. Apache runs on the Proxmox host and forwards the requests to the virtual machine via reverse proxy. Apache also runs on the virtual machines and calls the web applications via the document root.

Now the problem is that when I enter an existing directory into my URL, apache makes a redirect to the local IP of the virtual machine.

Example: https://example.com/admin --> makes a redirect to --> http://10.10.10.101/admin

Unfortunately, I've already spent several days trying to solve the problem and can't find the error.

Thank you for your help.

Setup Proxmox Host:

IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName www.example.com
    ServerAlias www.example.com

    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    ProxyPreserveHost On
    ProxyPass / http://10.10.10.101:80/
    ProxyPassReverse / http://10.10.10.101:80/
    Header add "Host" "www.example.com"
    RequestHeader set "Host" "www.example.com"

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>

Setup Virtual Machine:

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.example.com
ServerAlias www.example.com

Header add "Host" "www.example.com"
RequestHeader set "Host" "www.example.com"

DocumentRoot /var/www/www.example/current/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/www.example/current> Options +FollowSymLinks -Indexes AllowOverride All Require all granted

1 Answer 1

0

This is because based on you provided configuration there is no Alias or Severname that match with the request.

Try editing the ServerName as example.com instead of www.example or you can add it as ServerAlias

Example:

<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName example.com #Check this line
    ServerAlias www.example.com

    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    ProxyPreserveHost On
    ProxyPass / http://10.10.10.101:80/
    ProxyPassReverse / http://10.10.10.101:80/


    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .