2016-11-14 344 views
0

我使用wampserver作爲我的HTTP主機。我配置SSL允許HTTPS連接到我的網站。我遵循這個指導:[http://forum.wampserver.com/read.php?2,32986]。我自己用openssl自己生成了CRT和密鑰,但是我沒有將CSR發送給CA(我認爲除了瀏覽器會報告「不安全」報告之外沒有關係)。使用HTTPS時,您無權訪問此服務器

服務正常開始。我可以通過http://localhost/http://162.105.250.110/訪問我的網站。但是,當我嘗試通過HTTPS訪問網站時(通過網址https://localhost/https://162.105.250.110/,我收到403錯誤,頁面顯示「您無權訪問/在此服務器上」。)我該如何處理?


這裏是我的httpd配置文件(註釋行被刪除保存的話。)

httpd.conf文件:

ServerSignature On 
ServerTokens Full 



Define APACHE24 Apache2.4 
Define VERSION_APACHE 2.4.23 
Define INSTALL_DIR c:/wamp64 
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE} 

ServerRoot "${APACHE_DIR}" 



Listen 0.0.0.0:80 
Listen [::0]:80 

LoadModule access_compat_module modules/mod_access_compat.so 
LoadModule actions_module modules/mod_actions.so 
LoadModule alias_module modules/mod_alias.so 
LoadModule allowmethods_module modules/mod_allowmethods.so 
LoadModule asis_module modules/mod_asis.so 
LoadModule auth_basic_module modules/mod_auth_basic.so 
LoadModule auth_digest_module modules/mod_auth_digest.so 
LoadModule authn_core_module modules/mod_authn_core.so 
LoadModule authn_file_module modules/mod_authn_file.so 
LoadModule authz_core_module modules/mod_authz_core.so 
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so 
LoadModule authz_host_module modules/mod_authz_host.so 
LoadModule authz_user_module modules/mod_authz_user.so 
LoadModule autoindex_module modules/mod_autoindex.so 
LoadModule cache_module modules/mod_cache.so 
LoadModule cache_disk_module modules/mod_cache_disk.so 
LoadModule cgi_module modules/mod_cgi.so 
LoadModule dir_module modules/mod_dir.so 
LoadModule env_module modules/mod_env.so 
LoadModule file_cache_module modules/mod_file_cache.so 
LoadModule include_module modules/mod_include.so 
LoadModule isapi_module modules/mod_isapi.so 
LoadModule log_config_module modules/mod_log_config.so 
LoadModule mime_module modules/mod_mime.so 
LoadModule negotiation_module modules/mod_negotiation.so 
LoadModule rewrite_module modules/mod_rewrite.so 
LoadModule setenvif_module modules/mod_setenvif.so 
LoadModule ssl_module modules/mod_ssl.so 
LoadModule userdir_module modules/mod_userdir.so 
LoadModule vhost_alias_module modules/mod_vhost_alias.so 

LoadModule php7_module "${INSTALL_DIR}/bin/php/php7.0.10/php7apache2_4.dll" 

<IfModule unixd_module> 
User daemon 
Group daemon 

</IfModule> 


ServerAdmin [email protected] 

ServerName localhost:80 

<Directory /> 
    AllowOverride none 
    Require all denied 
</Directory> 

HostnameLookups Off 

DocumentRoot "${INSTALL_DIR}/www" 
<Directory "${INSTALL_DIR}/www/"> 
    Options +Indexes +FollowSymLinks +Multiviews 

    AllowOverride all 


    Require local 
</Directory> 

<IfModule dir_module> 
    DirectoryIndex index.php index.php3 index.html index.htm 
</IfModule> 

<Files ".ht*"> 
    Require all denied 
</Files> 

ErrorLog "${INSTALL_DIR}/logs/apache_error.log" 

LogLevel warn 

<IfModule log_config_module> 
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 
    LogFormat "%h %l %u %t \"%r\" %>s %b" common 

    <IfModule logio_module> 
     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 
    </IfModule> 

    CustomLog "${INSTALL_DIR}/logs/access.log" common 
</IfModule> 

<IfModule alias_module> 


    ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/" 

</IfModule> 

<IfModule cgid_module> 
</IfModule> 

<Directory "${INSTALL_DIR}/cgi-bin"> 
    AllowOverride None 
    Options None 
    Require all granted 
</Directory> 

<IfModule mime_module> 
    TypesConfig conf/mime.types 

    AddEncoding x-compress .Z 
    AddEncoding x-gzip .gz .tgz 
    AddType application/x-compress .Z 
    AddType application/x-gzip .gz .tgz 
    AddType application/x-httpd-php .php 
    AddType application/x-httpd-php .php3 

</IfModule> 

EnableSendfile off 

AcceptFilter http none 
AcceptFilter https none 

Include conf/extra/httpd-autoindex.conf 

Include conf/extra/httpd-vhosts.conf 

<IfModule proxy_html_module> 
Include conf/extra/proxy-html.conf 
</IfModule> 

<IfModule ssl_module> 
SSLRandomSeed startup builtin 
SSLRandomSeed connect builtin 
</IfModule> 
Include conf/extra/httpd-ssl.conf 

Include "${INSTALL_DIR}/alias/*" 

httpd-ssl.conf文件:

Listen 443 

SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4 
SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4 

SSLHonorCipherOrder on 

SSLProtocol all -SSLv3 
SSLProxyProtocol all -SSLv3 

SSLPassPhraseDialog builtin 

<VirtualHost _default_:443> 

DocumentRoot "c:/wamp64/www/" 
ServerName 162.105.250.110:443 
ServerAdmin [email protected] 
ErrorLog "c:/wamp64/bin/apache/apache2.4.23/logs/error.log" 
TransferLog "c:/wamp64/bin/apache/apache2.4.23/logs/access.log" 

SSLEngine on 

SSLCertificateFile "c:/wamp64/bin/apache/apache2.4.23/conf/ssl.crt/server.crt" 

SSLCertificateKeyFile "c:/wamp64/bin/apache/apache2.4.23/conf/ssl.key/server.key" 

<FilesMatch "\.(cgi|shtml|phtml|php)$"> 
    SSLOptions +StdEnvVars 
</FilesMatch> 
<Directory "c:/wamp64/www/"> 
Options Indexes FollowSymLinks MultiViews 
AllowOverride All 
Order allow,deny 
Require all granted 
</Directory> 

BrowserMatch "MSIE [2-5]" \ 
     nokeepalive ssl-unclean-shutdown \ 
     downgrade-1.0 force-response-1.0 

CustomLog "c:/wamp64/bin/apache/apache2.4.23/logs/ssl_request.log" \ 
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" 

</VirtualHost>         

回答

1

而且您的瀏覽器抱怨的證書,因爲它不是由已知的CA,沒什麼大不了的爲您的個人服務器簽名,因爲你會得到一個403,這意味着SSL已正確協商。

至於403錯誤。你正在混合2.2(訂單)與2.4指令(要求),這將導致問題。一旦你發現你訪問的DocumentRoot,添加您可能需要任何其他

<Directory "c:/wamp64/www/"> 
    Options Indexes FollowSymLinks MultiViews 
    Require all granted 
    AllowOverride none 
</Directory> 

試試這個。

注:

  • 我設置的AllowOverride到無,因爲:1°您可以訪問自己的服務器,因此你不需要它。 2º,它可能會覆蓋您在虛擬主機中的配置,並使用未粘貼的.htaccess文件進行配置。

  • 您應該卸載mod_access_compat並僅使用2.4指令來避免與2.2指令混淆。

+0

這個固定我的問題。你讓我知道'Require'和'Order'是做什麼的。 (我一直很困惑:P)。非常感謝! – cosmozhang

+0

只需記住Order/Allow-Deny是2.2指令,2.4是擺脫這種混淆的指令。更好地檢查有關升級的文檔,它會比我[升級](https://httpd.apache.org/docs/2.4/upgrading)更好地解釋你。html#運行時) –

0

同樣的問題發生在我身上,即使沒有HTTPS 我花了幾個小時與它戰鬥,它只是改變

的httpd-vhosts.conf位於wamp64 \ BIN \ apache的\ apache2.4.23 \的conf後工作\額外

<VirtualHost *:80> 
    ServerName localhost 
    DocumentRoot d:/wamp64/www 
    <Directory "d:/wamp64/www/"> 
     Options +Indexes +Includes +FollowSymLinks +MultiViews 
     AllowOverride All 
     Order Deny,Allow 
     Allow from all 
     Require all granted 
    </Directory> 
</VirtualHost> 

你也可以閱讀https://stackoverflow.com/a/26252312/3938407 我認真遵守它和它的作品

+0

Order和Allow/Deny是2.2指令。如果你將它們與需求(這是一個2.4指令)混合在一起,那麼你就會遇到麻煩。 –

相關問題