Apache 别名无法正常工作

Apache 别名无法正常工作

我的 CentOS 7 系统上有两个 NIC。一个是私有的,另一个是公共的。我对每个虚拟主机进行了以下配置

私有 IP 的虚拟主机

    ServerName localhost.com
    ServerAlias localhost.com.pk

    DocumentRoot /var/www/html/pub_local

    ErrorLog /var/log/httpd/local_error.log
    CustomLog /var/log/httpd/local_access.log combined  

Alias "/images/" "/srv/www/humkinar/"
    <Directory "/srv/www/humkinar/">
         Require all granted
    </Directory>

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

<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
 </IfModule>

</VirtualHost>

公网IP虚拟主机

<VirtualHost xx.xx.xx.xx:80>

    ServerName humkinar.com.pk
    ServerAlias www.humkinar.com.pk
    DocumentRoot /var/www/html/humkinar_ci

    ErrorLog /var/log/httpd/humkinar_error.log
    CustomLog /var/log/httpd/humkinar_access.log combined

# Alias for outsourcing images
   Alias "/images/" "/srv/www/humkinar/"

        <Directory "/srv/www/humkinar/">
                 Require all granted
        </Directory>
#========== outsourcing ends ============

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

<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
 </IfModule>
#from use.conf
<IfModule mod_expires.c>
ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"  
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
</VirtualHost>

当我从私有 IP 发送请求时,所有图像都加载成功,没有任何问题。但是当我运行请求时,有些图像可以加载,而有些图像无法通过实时 IP 访问,但实际上它们存在于目录中。问题出在哪里?

相关内容