chetan
chetan

Reputation: 3255

Redirect http to https by configuring .conf file of apache

I have configure apache to tomcat configuration by code like

<VirtualHost *:80>
ServerName captiveportal
ProxyPass       / http://ip:port/path
ProxyPassReverse / http://ip:port/path
</VirtualHost>

Now i want to reirect this request to https How can i achieve this ?

After looking your answer i have changes my configuration like

<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/etc/httpd/conf/crt1.crt"
SSLCertificateKeyFile "/etc/httpd/conf/key1.key"
ProxyPass       / http://ip:port/path
</VirtualHost>
<VirtualHost *:80>
ServerName captiveportal
Redirect / https://ip:port/path
</VirtualHost>

but when i type captiveportal on my browser it redirects me on url https://ip:port/path and it displays problem loading page

One more thing i don't want to display https://ip:port/path on browser.

Note :- https://ip:port/path where port is my tomcat port and ip is machine ip where tomcat run.

Upvotes: 1

Views: 17607

Answers (1)

larsks
larsks

Reputation: 311238

You could do something like this:

<VirtualHost *:80>
   ServerName captiveportal
   Redirect / https://my.host.name/
</VirtualHost>

...and then put your ProxyPass directives in side your SSL VirtualHost block instead.

Upvotes: 2

Related Questions