Apache Web服务器不提供DocumentRoot中的静态文件

问题描述 投票:0回答:1

我在/ var / www / html中放了一个health.html文件并尝试使用http://localhost/health.html打开,但是它会转到app-server-endpoint,因此给出404错误。如何更改我的apache配置,以便能够提供DocumentRoot中存在的静态文件,而无需转到使用ProxyPass配置的app-server-endpoint。

Apache版本细节:

Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
Server built:   Jun 22 2018 01:19:25

这是我的httpd.conf文件:

ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
ServerName localhost
<Directory />
    AllowOverride none
    Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    Order allow,deny
    Allow from all
</Directory>
<VirtualHost _default_:80>
    DocumentRoot "/var/www/html"
</VirtualHost>
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "logs/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 "logs/access_log" combined
</IfModule>
<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
RewriteEngine ON
ProxyRequests Off
ProxyPreserveHost On
KeepAlive ON
KeepAliveTimeout 15
Timeout 6000
ProxyTimeout 6000
AddOutputFilterByType DEFLATE text/html text/plain
DeflateCompressionLevel 9
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
DeflateFilterNote ratio
SetEnv proxy-sendcl
SetEnv proxy-sendchunks
TraceEnable Off
ExpiresActive On
ExpiresDefault "access plus 30 minutes"
ExpiresByType text/html "access plus 0 minutes"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType text/x-json "access plus 1 day"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
<FilesMatch ".(gif|jpg|jpeg|png|flv|swf|ico|js|css|pdf)$">
Header add Cache-Control "max-age=315360000, public"
</FilesMatch>
Header add X-Frame-Options "SAMEORIGIN"
Header unset Server
ServerTokens Prod
ServerSignature Off
Header set Access-Control-Allow-Origin "POST"
ProxyPassMatch ^/(.*)  http://<app-server-endpoint>:8080
ProxyPassReverse / http://<app-server-endpoint>:8080
apache configuration
1个回答
0
投票

我在ProxyPassMatch ^/(.*) http://<app-server-endpoint>:8080之前添加了以下代码,它解决了这个问题。

ProxyPass /health.html !
© www.soinside.com 2019 - 2024. All rights reserved.