【发布时间】:2020-12-11 05:11:21
【问题描述】:
背景:我在 RHEL 7 上运行 Apache 2.4.25。现有网站已经存在多年,现在我想添加一个运行 Angular 的其他无关网站。
主要问题:无论我做什么,我都无法将流量路由到新网站。
预期行为:现有站点继续在 8443 上运行,新站点在 10443 上运行。
实际行为:现有站点在 8443 和 10443 上侦听,但新站点在两者上都返回 404。
文件系统位置:
- Apache 服务器:/opt/intapache/
- 现有(功能性)站点:/opt/cspgateway/
- 新的(非功能性)站点:/opt/intapache/htdocs/(注意:此目录中的 index.html 设置为 755 文件访问)
当前文件:http.conf 指向第二个conf
httpd.conf:
ServerRoot "/opt/intapache/"
Listen 8443
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule socache_dbm_module modules/mod_socache_dbm.so
LoadModule socache_memcache_module modules/mod_socache_memcache.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
<IfModule unixd_module>
User cachedb
Group cachedb
</IfModule>
ServerAdmin you@example.com
ServerName example.com
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/opt/cspgateway/csp"
<Directory "/opt/cspgateway/csp">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<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" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/opt/intapache//cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "/opt/intapache/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
</IfModule>
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include conf/extra/cspgateway.conf
cspgateway.conf
<VirtualHost *:8443>
DocumentRoot /opt/cspgateway/csp
ServerName example.com
SSLEngine on
SSLCertificateFile "/opt/example.crt"
SSLCertificateKeyFile "/opt/example.key"
SSLCertificateChainFile "/opt/chaincert.crt"
SSLProtocol All -SSLv2 -SSLv3 +TLSv1.2
</VirtualHost>
Listen 10443
<VirtualHost *:10443>
DocumentRoot /opt/intapache/htdocs
ServerName example.com
SSLEngine on
SSLCertificateFile "/opt/example.crt"
SSLCertificateKeyFile "/opt/example.key"
SSLCertificateChainFile "/opt/chaincert.crt"
SSLProtocol All -SSLv2 -SSLv3 +TLSv1.2
<Directory "/opt/intapache/htdocs">
AllowOverride None
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
LoadModule csp_module_sa /opt/cspgateway/bin/CSPa24.so
CSPModulePath /opt/cspgateway/bin/
<Location "/csp/bin/Systems/">
SetHandler cspsys-handler-sa
</Location>
<Location "/csp/bin/RunTime/">
SetHandler csp-handler-sa
</Location>
<Location />
CSP On
</Location>
CSPFileTypes csp cls zen cxw gif jpeg jpg jpe png sgi svg svgz tiff tif ico
Alias /csp/ /opt/cspgateway/csp/
<Directory "/opt/cspgateway/csp">
AllowOverride None
Options MultiViews FollowSymLinks ExecCGI
Order allow,deny
Allow from all
<FilesMatch "\.(log|ini|pid|exe)$">
Deny from all
</FilesMatch>
</Directory>
## START SDS-POC CONFIG ##
<Directory "/opt/intapache/htdocs">
AllowOverride None
Options MultiViews FollowSymLinks ExecCGI
Require all granted
</Directory>
## END SDS-POC CONFIG ##
SSLSessionCache "shmcb:logs/ssl_scache(512000)"
【问题讨论】:
-
您在“3”个地方进行了配置。在泛型(任何VirtualHost 之外)和2 个VirtualHost 中。这非常令人困惑。在通用部分中,为所有站点设置相同的指令。然后,与每个站点相关的所有内容都应包含在其特定的 VirtualHost 中。话虽如此,您应该缩进您的配置,以便清楚地识别每个部分。