[問題] 在Apache上啟動VirtualHost使用HTTP和HTTPS

作者: wyytw (雲飛揚)   2018-11-21 09:36:04
怎樣在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同時運作 ??
謝謝
作者: wyytw (雲飛揚)   2018-11-21 11:02:00
httpd-2.4.6-80.el7.centos.x86_64不過我改成 *:80 和*:443就可以了謝謝ㄧ樓
作者: kdjf (我抓得到什麼呢?)   2018-11-21 10:48:00
你根本沒搞懂virtualhost... 怎麼會用IP指定呢?然後給個發行版/版號,問題可能不在單這一個設定檔

Links booklink

Contact Us: admin [ a t ] ucptt.com