【问题标题】:Enable Basic Authentication in Lucee (tomcat) with Apache使用 Apache 在 Lucee (tomcat) 中启用基本身份验证
【发布时间】:2017-03-24 12:37:37
【问题描述】:

我将 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

【问题讨论】:

  • 请添加您的 Apache 配置,了解如何将 CF 页面的请求发送到 Tomcat 以及如何将虚拟主机发送到上述内容。如果不知道你做了什么,就不可能说它为什么不工作,但这不是 Tomcat/Lucee 的问题,这将与你如何配置 Apache 有关。

标签: tomcat authentication coldfusion lucee


【解决方案1】:

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

也尝试添加:

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

就在Require valid-user 行之后。

【讨论】:

  • 我根据您的建议更新了配置,但没有解决问题。系统提示我登录,但是当我点击取消时,请求仍被代理到 tomcat。 - 我将在上面的问题中发布我的更新配置。
猜你喜欢
  • 2012-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多