【问题标题】:You don't have permission to access / on this server when using HTTPS使用 HTTPS 时您无权访问此服务器上的 /
【发布时间】:2017-03-28 05:58:00
【问题描述】:

我使用 wampserver 作为我的 HTTP 主机。我将 ssl 配置为允许 HTTPS 连接到我的站点。我遵循了这个指导:[http://forum.wampserver.com/read.php?2,32986]。我使用openssl 自己生成了 CRT 和密钥,但我没有将 CSR 发送给 CA(我认为这无关紧要,只是浏览器会报告“不安全”报告)。

服务正常启动。我可以通过http://localhost/http://162.105.250.110/ 访问我的网站。但是当我尝试通过 HTTPS 访问该站点时(通过 URL 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 wampserver@wampserver.invalid

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 admin@example.com
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>                                  

【问题讨论】:

    标签: php apache ssl https httpd.conf


    【解决方案1】:

    此外,您的浏览器也会抱怨该证书,因为它没有由已知的 CA 签名,对您的个人服务器来说没什么大不了的,而且由于您收到 403,这意味着 SSL 已正确协商。

    至于 403 错误。您将 2.2(订单)与 2.4 指令(要求)混合,这将导致问题。

    试试这个:

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

    一旦您注意到您可以访问文档根目录,请添加您可能需要的任何其他内容。

    注意事项:

    • 我将 AllowOverride 设置为 none,因为:1º 您可以访问自己的服务器,因此您不需要它。 2º 它可能会使用您尚未粘贴的 .htaccess 文件中的配置覆盖您在虚拟主机中的配置。

    • 您应该卸载 mod_access_compat 并仅使用 2.4 指令,以避免错误地与 2.2 指令混合。

    【讨论】:

    • 这解决了我的问题。你让我知道RequireOrder 做了什么。 (我已经困惑了很长时间:P)。非常感谢!
    • 请记住 Order/Allow-Deny 是 2.2 指令,而 2.4 是消除这种混乱的唯一指令。最好查看有关升级的文档,它会比我解释得更好Upgrading
    • 我在 2020 年遇到了同样的问题,但无法通过此指令解决。还有其他问题吗?
    • 所以我的问题出在 httpd-ssl.conf 中的 DocumentRoot "${SRVROOT}/www" 上。在我的情况下,它必须是 c:/wamp64-3-2-0/www。
    【解决方案2】:

    即使没有 HTTPS,我也会遇到同样的问题 我花了几个小时与它作斗争,它只有在改变后才能工作

    httpd-vhosts.conf 位于 wamp64\bin\apache\apache2.4.23\conf\extra

    <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 我仔细遵循了它,它有效

    【讨论】:

    • Order 和 Allow/Deny 是 2.2 指令。如果将它们与 2.4 指令的 Require 混合使用,那么您一定会遇到麻烦。
    猜你喜欢
    • 2017-02-26
    • 2013-06-30
    • 2019-02-22
    • 2020-09-10
    • 2017-05-04
    • 2015-10-06
    • 2015-10-07
    相关资源
    最近更新 更多