我在一台服务器上托pipe两个网站。 每个都有自己的VirtualHost定义。 第一个网站很好地工作,但当我尝试访问第二个我redirect到第一个。 这就像Apache不能识别ServerName的正确的VirtualHost,并将我redirect到默认(第一)网站。 有没有日志或什么东西,我可以看到Apache处理我的请求时采取了哪些步骤? 当它试图find一个匹配的VirtualHost时,是否在任何地方logging了它所使用的ServerName? 更新: 我为我的第二个网站的子域添加了一个VirtualHost部分,并且工作正常。 当我在浏览器中input“interface.domain.com”时,它会从正确的运行在8501端口的应用程序服务器中呈现页面。 但是,当我尝试“www.domain.com”redirect到我的第一个网站。 以下是我的第二个站点的虚拟主机文件。 <VirtualHost *:80> ServerName www.domain.com DocumentRoot /home/domain/current/public RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ http://localhost:8501/$1 [P] </VirtualHost> <VirtualHost *:80> ServerName interface.domain.com DocumentRoot /home/domain/current/public RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ http://localhost:8501/$1 [P] </VirtualHost> apache2ctl -S AH00558: apache2: Could not reliably determine the server's fully qualified […]
我有一个虚拟主机,它有一些像这样configuration访问限制: <Location "/"> AuthType Basic AuthName "Restricted Content" AuthUserFile /var/www/domain/htdocs/.htpasswd Require valid-user </Location> 除此之外,我还有以下conf文件: Alias /.well-known/acme-challenge/ "/var/www/letsencrypt/" <Location /.well-known/acme-challenge/> # Security Options Options None AllowOverride None ForceType text/plain RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)" # Do not redirect to https or perform other rewrites RewriteEngine off </Location> 我需要/.well-known/acme-challenge/才能无需授权即可访问。 我已经尝试添加不同的Require all granted我的conf文件,但无济于事。 我如何使/.well-known/acme-challenge/无需身份validation访问所有的虚拟主机? (我不想修改任何虚拟主机,这个虚拟主机就是一个例子)。
我为一个站点启用了HTTPS,所有对HTTP的请求现在都应该redirect到HTTPS, 除了一个目录的内容,例如/downloads 。 我改变了我的VirtualHostconfiguration为HTTP,并添加了RedirectMatch设置: <VirtualHost *:80> ServerName example.com RedirectMatch 302 ^/(?!download/).*$ https://example.com$1 ProxyPreserveHost On ProxyRequests Off ProxyPass / http://10.0.0.11:3000/ ProxyPassReverse / http://10.0.0.11:3000/ </VirtualHost> # configuration for HTTPS down here, working fine 我的期望:诸如http://example.com/faq请求将被redirect到HTTPS版本,并且所有请求(如http://example.com/download/file.zip仍然是HTTP。 但显然, Proxy*指令具有更高的优先级,根本不会发生redirect。 我将如何正确构build我的configuration,以便我可以使用RedirectMatch ,并在不匹配的情况下使用Proxy*设置?
传统应用程序通过Slim框架传递所有传统的PHP文件请求到index.php在.htaccess文件。 此外,Symfony应用程序在设置了别名的文件夹中设置。 用PHP-FPM进行VHostconfiguration <VirtualHost *:80> ServerName example.com DocumentRoot /path/to/app/slim Alias /system /path/to/app/symfony <IfModule mpm_itk_module> AssignUserId web_user web_user </IfModule> <LocationMatch "^(.*\.php)$"> ProxyPass fcgi://127.0.0.1:9001/path/to/app/slim </LocationMatch> </VirtualHost> testing文件: /path/to/slim/index.php <?php echo "slim"; /path/to/slim/.htaccess RewriteEngine On RewriteBase / RewriteRule ^hello$ /hello.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] /path/to/slim/hello.php: <?php echo "hello"; /path/to/symfony/app.php <?php echo "symfony"; […]
在这里遇到了一个问题,我find了很less的信息,我希望有人能够说明一些问题。 我正在升级服务器从Apache 2.2到Apache 2.4。 在该服务器中,有一个设置可以在apacheconfiguration中redirect到其他本地托pipe的站点。 该设置的问题是它使用指令RewriteLog和RewriteLogLevel将输出redirect到一个单独的日志,而不是通常的主机日志。 阅读两个版本的Apache(2.2与2.4)之间的变化,看起来像RewriteLog和RewriteLogLevel已被弃用,并用mod_rewrite取代。 这一切都很好,但我没有find在mod_rewrite中提到的一个函数,它允许我定义一个单独的日志文件来写出在Apache中的该网站的重写调用。 有没有人有任何有用的提示或可以指出我在一个很好的方向,可以解释如何redirect输出到mod_rewrite内的新日志? 谢谢!
我试图用apache 2.4.10 unix套接字,我不断收到错误No protocol handler was valid for the URL /foo. 我已经安装并启用了mod_proxy_uwscgi 。 我的虚拟主机看起来像这样: <VirtualHost *:80> ServerAdmin [email protected] ServerName foo.example.com <Location /> ProxyPass unix:/path/to/socket.sock|uwscgi:// </Location> </VirtualHost> apachectl -M输出 Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module […]
我有两个安装在Ubuntu 16.04 VPS上的Apache虚拟主机。 site1.example.com是一个function正常的WordPress网站。 site2.example.com是一个新增的网站,其文档根目录中只有index.php 。 当我在浏览器中访问site2.example.com时,它意外地redirect到site1.example.com (WP网站)。 但是,如果我访问site2.example.com/index.php将按预期方式显示。 以下是/etc/apache2/sites-available中的.conf文件的内容: site1.conf: <VirtualHost *:80> ServerName site1.example.com DirectoryIndex index.html index.php DocumentRoot /var/www/html/site1.example.com/public_html </VirtualHost> site2.conf: <VirtualHost *:80> ServerName site2.example.com DirectoryIndex index.html index.php DocumentRoot /var/www/html/site2.example.com/public_html </VirtualHost> 我能做些什么来让http://site2.example.com/显示index.php而不需要在URL中明确要求? 如果有人有任何build议或需要看到我的configuration的另一部分,请让我知道。
Apache Httpd被用作两个端点服务器之间的负载平衡器。 每个服务器都有自己的HTTPauthentication。 目标是将端点身份validation传递给用户,用户input其凭据,并将身份validation传回到terminal服务器。 当我将Apache设置为反向代理时,身份validation将毫无问题地通过。 当我到本地主机,我得到提示凭据,我input他们,然后网站工作正常。 这是我的反向代理的configuration: <VirtualHost *:80> ProxyPass "/" "http://serv123:27001/" ProxyPassReverse "/" "http://serv123:27001/" <Location "/"> SetEnv proxy-chain-auth On </Location> </VirtualHost> 但是,当我添加负载平衡,似乎proxy-chain-authconfiguration不正确。 当我input凭据时,我立即得到提示,好像他们没有正确input。 <VirtualHost *:80> ProxyPass "/" "balancer://mycluster/" ProxyPassReverse "/" "balancer://mycluster/" <Location "/"> SetEnv proxy-chain-auth On </Location> <Proxy "balancer://mycluster"> BalancerMember "http://serv123:27001/" BalancerMember "http://serv456:27001/" </Proxy> </VirtualHost> 我也尝试过<Location "balancer://mycluster">和<Location "balancer://mycluster/"> ,但没有成功。 有谁知道正确的方式通过负载平衡的Apache Httpd身份validation?
操作系统Ubuntu Ubuntu 16.04.2 LTS Apache / 2.4.18 Perl v5.22.1 所以我有perl代码读取一个MySQL数据库,然后创build一个dynamic网页。 代码已经工作了很多年了。 一个星期前,我的客户打来电话,说他们正在收到500条内部服务器信息。 我看看,一切似乎都很好,但是当我尝试加载页面,我得到500错误。 在Apache错误日志中,有这个错误: [Tue May 30 22:16:13.144199 2017] [http:error] [pid 12487] [client 99.99.99.99:55628] AH02429: Response header name '<!– warning' contains invalid characters, aborting request 有没有人看到这个,或者有什么想法是什么造成的?
我有一个网站,目前正在从一个旧的CMS迁移到一个新的(Laravel)。 只有一些网站的语言已经被转移到Laravel。 所以基本上,我的虚拟主机的根文件夹是这样的: [D] staticContentDirectory1 [D] staticContentDirectory2 … [D] oldCmsDirectory1 [D] oldCmsDirectory2 … [D] oldCmsDirectoryN [D] public [F] index-of-the-old-cms-still-in-use.php 我有一个.htaccess文件,将旧CMS或静态内容目录中没有处理的所有内容redirect到Laravel,如下所示: RewriteRule ^((?!staticContentDirectory1|staticContentDirectory2|public)(.*))$ public/$1 [L] Laravel也有公开的.htaccess来处理它的东西。 到目前为止,一切工作都很完美,我们对结果非常满意(给定初始约束条件)。 我们发现了一个问题。 不知何故,谷歌设法发现/public存在并抓取它,导致与/public/里面,从那以后创build/public/public/ URLs(幸运的是,返回一个500错误,避免无限的URL)。 在修复CMS和robots.txt之前,我们试图通过将stream量从/public重写/redirect到/来解决这个问题。 很多事情都经过了尝试,发生了很多失败,几乎全部都是无限循环的redirect。 因为每个Apache模块似乎都是自己做的,混合RedirectMatch和RewriteRule失败了。 RewriteCond和RewriteRule是无限的redirect或完全忽略。 TL; DR:我现在正在寻求帮助:如何将RewriteRule /folder到/folder ,然后将所有stream量从该文件夹redirect到根目录。