Apache Web 伺服器問題

Apache Web 伺服器問題

在新增證書之前,我可以訪問以下站點

http://website.com:4043/web/login

但是添加證書後我無法使用 https 訪問完整的 URL。
但是我只能訪問https://website.com

請任何支持。

答案1

假設您正在執行現代版本的 Ubuntu,您將需要確保您的 Apache 虛擬設定檔如下所示:

Listen 443
Listen 4043

<VirtualHost *:443>
    ServerName website.com

    SSLProxyEngine on
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:4043>
    ServerName website.com

    SSLProxyEngine on
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/server.crt
    SSLCertificateKeyFile /etc/ssl/private/server.key
    DocumentRoot /var/www/html
</VirtualHost>

從這裡,您可以設定一個快速的小.htaccess規則,以確保流量正確重定向到4043而不是伺服器預設的443.例如:

RewriteEngine on

# If the port isn't 4043
RewriteCond %{SERVER_PORT} !^4043$

# We redirect to the same address with the proper port
RewriteRule ^(.*)$ https://%{HTTP_HOST}:4043/$1 [R=301,L]

重要的:不要簡單地複製和貼上這些東西。看文字,針對自己的環境進行調整,這是大家都不知道的除了你。

相關內容