I have 2 virtual host tags in my conf file.
1st Tag contains the redirect rule for request coming through internal IP address.
2nd Tag contains the other redirect rules for request coming through public ip or any other place
When I remove the first VirtualHost tag, redirect and ssl works perfectly fine, but I need the first VirtualHost tag as well
My conf file
this is located at /etc/apache2/sites-available/site.conf
<VirtualHost 10.1.0.7:80>
ProxyPreserveHost On
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName servername.com
ProxyPass /Service http://localhost:8080/Service
ProxyPassReverse /Service http://localhost:8080/Service
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName servername.com
RewriteEngine On # Turn on the rewriting engine
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
If I remove the first VirtualHost tag which contains the private IP, everything works fine, but as soon as I add it, the server does not redirect to 443 port.
My ssl conf file:
located at /etc/apache2/sites-available/site-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ServerName server.com
# Redirections:
ProxyPass /server-status http://localhost:7570/server-status
ProxyPassReverse /server-status http://localhost:7570/server-status
ProxyPass /mCare/subscribe ws://localhost:8080/mCare/subscribe
ProxyPassReverse /mCare/subscribe ws://localhost:8080/mCare/subscribe
ProxyPass /mCare http://localhost:8080/mCare
ProxyPassReverse /mCare http://localhost:8080/mCare
ProxyPass /solr http://localhost:8280/solr
ProxyPassReverse /solr http://localhost:8280/solr
SSLEngine on
SSLCertificateFile /mnt/opt/ssl/2015/sha2/b89516b0cdc9a701.crt
SSLCertificateKeyFile /mnt/opt/ssl/2015/sha2/mcare.pem
SSLCertificateChainFile /mnt/opt/ssl/2015/sha2/gd_bundle.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
This is my ports.conf file :
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>