Apache rewrite rules to direct certain URLs to the Virtual Machines

coryjsanders

New Member
Jun 28, 2013
7
0
1
I am trying to use Apache rewrite rules to direct certain URLs to the Virtual Machines on my ProxMox server.

My public IP is on eth0. So you get to the ProxMox gui by going my.pub.lic.ip:8006 I have not changed anything in /etc/apache2/sites-available

I am using CSF as my firewall.

The VMs are running vmbr0 I have it configured so I can ssh into the VMs.

The VM's guis are on https already and have their own self-signed cert.

The VMss are on vmbr0 and running on 10.10.10.x

I want a URL such as mycustomer.mydomain.com (which is being forwarded from my hosting provider to my.pub.lic.ip) to be received by Apache and redirected to the VM either by private IP or domain name.

Here is the contents of one of my VM's /etc/apache2/sites-available/default

<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !^.*Aastra.*0
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME} [L,R]
</VirtualHost>

Here is the contents of one of my VM's /etc/apache2/sites-available/default-ssl

<IfModule mod_ssl.c>
NameVirtualHost *:443
<VirtualHost *:443>
ServerAdmin mydomain.org
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature Off

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>
</IfModule>






Thanks.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!