在Apache上啟動VirtualHost使用HTTP和HTTPS - Linux

Table of Contents

怎樣在Apache上啟動VirtualHost使用HTTP和HTTPS同時運作

還沒使用VirtualHost的時候

A網頁已經設定好SSL Https

也可以正常使用https://server.a.com

如今要加入ㄧ個B網頁http ( 沒有用SSL ) http://server.b.com

如今想要使用VirtualHost來完成這個設定

不過沒有成功

設定檔如下

<VirtualHost 123.123.123.123:80>
# ServerAdmin [email protected]
DocumentRoot /web/server.b.com
ServerName server.b.com
<Directory "/web/server.b.com">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost 123.123.123.123:443>
# ServerAdmin [email protected]
DocumentRoot /web/server.a.com
ServerName server.a.com
<Directory "/web/server.a.com">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

使用這樣的設定結果

https://server.a.com

可以顯示正確的htttps的網頁

不過http://server.b.com

則顯示的網頁不正確,會顯示出server.a.com網頁的內容,不過並沒有SSL瀏覽

而我在apache網頁看到這段問題說明

https://wiki.apache.org/httpd/FAQ#SSIs_don.27t_work_for_VirtualHosts_and.2For_user_home_directories.

SSIs don't work for VirtualHosts and/or user home directories.

This is almost always due to having some setting in your config file that sets

"Options Includes" or some other setting for your DocumentRoot but not for other

directories. If you set it inside a Directory section, then that setting will

only apply to that directory.

請問一下是否確定Apache的virtualHost並不支援http和https同時運作 ??

謝謝

--

All Comments

Tom avatarTom2018-11-25
你根本沒搞懂virtualhost... 怎麼會用IP指定呢?
Tracy avatarTracy2018-11-25
然後給個發行版/版號,問題可能不在單這一個設定檔
Lauren avatarLauren2018-11-27
httpd-2.4.6-80.el7.centos.x86_64
George avatarGeorge2018-11-29
不過我改成 *:80 和*:443就可以了
謝謝ㄧ樓