gpt4 book ai didi

tomcat - 使用 Apache 在 Lucee (tomcat) 中启用基本身份验证

转载 作者:行者123 更新时间:2023-11-28 22:17:03 25 4
gpt4 key购买 nike

我将 apache 与 Lucee (tomcat) 一起使用。我有一个开发站点,我希望它支持基本身份验证。我有 apache 配置和非 ColdFusion 页面需要并提示进行身份验证。当我导航到 CF 页面时,不需要基本身份验证。

我需要修改什么 Tomcat/Lucee 配置文件才能在设置附加基本身份验证时使用 apache 基本身份验证?

我正在运行 Apache/2.4.10 (Debian)

这是我的站点配置文件:

<VirtualHost *:80>
ServerName dev.mysite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mysite.com/dev/docroot

<Directory /var/www/mysite.com/dev>
Options Indexes FollowSymLinks
AllowOverride All
AuthName "Secured Development Environment"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
DirectoryIndex index.cfm index.html
</Directory>


ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这是 Lucee 添加到我的 apache2.conf 文件中的内容

<IfModule mod_proxy.c>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ http://127.0.0.1:8888/$1$2
ProxyPassMatch ^/(.+\.cfchart)(/.*)?$ http://127.0.0.1:8888/$1$2
ProxyPassMatch ^/(.+\.cfml)(/.*)?$ http://127.0.0.1:8888/$1$2
# optional mappings
#ProxyPassMatch ^/flex2gateway/(.*)$ http://127.0.0.1:8888/flex2gateway/$1
#ProxyPassMatch ^/messagebroker/(.*)$ http://127.0.0.1:8888/messagebroker/$1
#ProxyPassMatch ^/flashservices/gateway(.*)$ http://127.0.0.1:8888/flashservices/gateway$1
#ProxyPassMatch ^/openamf/gateway/(.*)$ http://127.0.0.1:8888/openamf/gateway/$1
#ProxyPassMatch ^/rest/(.*)$ http://127.0.0.1:8888/rest/$1
ProxyPassReverse / http://127.0.0.1:8888/
</IfModule>

这是我根据推荐的更新配置

我根据您的建议更新了我的配置,但并没有解决问题。

<VirtualHost *:80>
ServerName dev.mysite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mysite.com/dev/docroot

<Directory /var/www/mysite.com/dev>
Options Indexes FollowSymLinks
AllowOverride All
AuthName "Secured Development Environment"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
DirectoryIndex index.cfm index.html
</Directory>


<IfModule mod_proxy.c>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ http://127.0.0.1:8888/$1$2
ProxyPassMatch ^/(.+\.cfchart)(/.*)?$ http://127.0.0.1:8888/$1$2
ProxyPassMatch ^/(.+\.cfml)(/.*)?$ http://127.0.0.1:8888/$1$2
ProxyPassReverse / http://127.0.0.1:8888/
</IfModule>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这不起作用,我不确定它有什么不同,因为虚拟主机包含在 IfModule 之前

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

最佳答案

请求在到达您的 VirtualHost 之前被代理到 Tomcat。移动 <IfModule>东西进入 <VirtualHost><Directory>之后定义。您需要为每个虚拟主机执行此操作,因此您可能希望将其弹出到一个单独的文件中,然后使用 Include 指令将其包含在内。

也尝试加入:

<Limit GET POST>
order deny,allow
satisfy any
deny from all
require valid-user
</Limit>

就在Require valid-user之后行。

关于tomcat - 使用 Apache 在 Lucee (tomcat) 中启用基本身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42999730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com