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

看板Linux作者 (雲飛揚)時間5年前 (2018/11/21 09:36), 編輯推噓0(005)
留言5則, 2人參與, 5年前最新討論串1/1
怎樣在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 webmaster@dummy-host.example.com 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 webmaster@dummy-host.example.com 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同時運作 ?? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.75.167.66 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1542764168.A.DC4.html

11/21 10:48, 5年前 , 1F
你根本沒搞懂virtualhost... 怎麼會用IP指定呢?
11/21 10:48, 1F

11/21 10:57, 5年前 , 2F
然後給個發行版/版號,問題可能不在單這一個設定檔
11/21 10:57, 2F

11/21 11:02, 5年前 , 3F
httpd-2.4.6-80.el7.centos.x86_64
11/21 11:02, 3F

11/21 11:03, 5年前 , 4F
不過我改成 *:80 和*:443就可以了
11/21 11:03, 4F

11/21 11:03, 5年前 , 5F
謝謝ㄧ樓
11/21 11:03, 5F
文章代碼(AID): #1RzBQ8t4 (Linux)