【发布时间】:2025-12-19 04:25:11
【问题描述】:
我有两个网络服务器在同一台机器上运行,地址如下:
internal.myservername.com
和
test.myservername.com
测试站点(在某些页面上)从内部站点提取图像,并且运行良好。现在我们已经完成了测试,我想将测试域添加/更改为主站点,所以我将 myservername.com 的 apache 服务器别名添加到测试站点,但是虽然所有页面都可以正常工作,但来自内部的任何图像都会没有显示在那个地址上,导致 403 错误:
[access_compat:error] AH01797: client denied by server configuration
我还尝试将 myservername.com 设置为自己的域,并尝试将其设置为测试站点上的主要名称(以 test 为别名)。在所有情况下,test.myservername.com 都能正常工作并正确显示图像,而 myservername.com 则不能(导致这些嵌入图像出现所有 403 错误)。
我检查了所有配置,没有发现任何问题。我的 .htaccess 文件或 conf 文件中没有任何特定于“测试”的内容。我被难住了。
我可能还应该提到我在 Mac OS Sierra 服务器上运行。 (服务器版本:Apache/2.4.23 (Unix))
按照要求的详细信息进行更新:
- img标签:图片标签没有什么特别的,都是用完整的url调用的,即
<img src="http://internal.myservername.com/images/imagename.jpg" />
我还应该补充一点,如果我获取确切的 src url 并将其单独粘贴到浏览器中,图像将加载。它仅嵌入在拒绝加载的页面中。 (并且仅在主域上,测试嵌入在 img 标签中可以正常工作)
-
而test/main conf的设置是:
<VirtualHost 127.0.0.1:34580> ServerName http://test.myservername.com:80 ServerAdmin admin@example.com DocumentRoot "/Library/Server/Web/Data/Sites/myservername.com/plugins/mywebsite" DirectoryIndex index.php home.php index.html CustomLog /var/log/apache2/access_log combinedvhost ErrorLog /var/log/apache2/error_log <IfModule mod_ssl.c> SSLEngine Off SSLCipherSuite "HIGH:MEDIUM:!MD5:!RC4:!3DES" SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2 SSLProxyEngine Off SSLProxyProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2 </IfModule> <IfModule mod_secure_transport.c> MSTEngine Off MSTCipherSuite HIGH, MEDIUM MSTProtocolRange TLSv1.2 TLSv1.2 MSTProxyEngine On MSTProxyProtocolRange TLSv1.2 TLSv1.2 </IfModule> <Directory "/Library/Server/Web/Data/Sites/myservername.com/plugins/mywebsite"> Options All -Indexes +ExecCGI +Includes +MultiViews AllowOverride All <IfModule mod_dav.c> DAV Off </IfModule> <IfDefine !WEBSERVICE_ON> Require all denied ErrorDocument 403 /customerror/websitesoff403.html </IfDefine> </Directory> ServerAlias myservername.com -
以及内部配置:
<VirtualHost 127.0.0.1:34580> ServerName http://internal.myservername.com:80 ServerAdmin admin@example.com DocumentRoot "/Library/Server/Web/Data/Sites/myservername.com" DirectoryIndex index.php CustomLog /var/log/apache2/access_log combinedvhost ErrorLog /var/log/apache2/error_log <IfModule mod_ssl.c> SSLEngine Off SSLCipherSuite "HIGH:MEDIUM:!MD5:!RC4:!3DES" SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2 SSLProxyEngine Off SSLProxyProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2 </IfModule> <IfModule mod_secure_transport.c> MSTEngine Off MSTCipherSuite HIGH, MEDIUM MSTProtocolRange TLSv1.2 TLSv1.2 MSTProxyEngine On MSTProxyProtocolRange TLSv1.2 TLSv1.2 </IfModule> <IfModule mod_headers.c> <filesmatch "^.*www.*\.jpg$"> Header set Cache-Control "max-age=2678400, public" </filesmatch> </IfModule> <Directory "/Library/Server/Web/Data/Sites/myservername.com"> Options All -Indexes +ExecCGI +Includes +MultiViews AllowOverride All Require all granted <IfModule mod_dav.c> DAV Off </IfModule> <IfDefine !WEBSERVICE_ON> Require all denied ErrorDocument 403 /customerror/websitesoff403.html </IfDefine> </Directory> </VirtualHost>
【问题讨论】:
-
我怀疑这个问题可能与您调用图像的方式以及响应图像的服务器有关,而不是与附加域的设置有关。但这只是一种狂野的直觉。如果您同时发布
vhost.conf文件以及示例 HTML 源代码示例<img>标记和/或图像请求的Network选项卡输出,那肯定会有所帮助。 -
已更新请求的信息,感谢您的评论。
标签: apache http-status-code-403