如何在 Ubuntu 上安裝 Railo 和 Apache 並讓它將基本驗證使用者名稱傳遞給 Railo?

如何在 Ubuntu 上安裝 Railo 和 Apache 並讓它將基本驗證使用者名稱傳遞給 Railo?

我正在嘗試從使用 Adob​​e ColdFusion 轉向使用 Railo。我嘗試遷移的應用程式依賴於讓網頁伺服器檢查基本身份驗證,但隨後需要使用該#REMOTE_USER#變數來了解經過身份驗證的使用者的使用者名稱。

我嘗試轉儲 cgi 範圍,但似乎變數未設定。我已經花了大約一周的時間努力讓這一切順利進行,但陷入了困境。

答案1

所以,我終於想通了。就像它說的那樣,我至少花了一周的時間才得到這個。因此,我正在分享有關如何為此設置一台新機器的筆記,這樣其他人就不必像我一樣花那麼多時間來解決這個問題。關鍵的事情似乎是你想使用 AJP 協定而不是 HTTP 來代理 Railo,並且你想告訴 tomcat 它不需要進行身份驗證(這將讓它不受影響地傳遞變數)。

讓我們開始吧:

apt-get install apache2 mysql-server apache2-utils
a2enmod proxy_ajp
service apache2 restart

安裝 Railo:

下載頁面上列出的標準安裝程式 64 位元版本:http://www.getrailo.org/index.cfm/download/

使其可執行:

chmod +x <file_you_just_downloaded>

運行:

./<file_you_just_downloaded>

選擇所有預設值。

好的,現在像這樣編輯設定檔:

=== modified file '/etc/apache2/apache2.conf'
--- /etc/apache2/apache2.conf 2014-10-10 00:22:11 +0000
+++ /etc/apache2/apache2.conf 2014-10-10 00:27:48 +0000
@@ -223,18 +223,24 @@
<IfModule mod_proxy.c>
<Proxy *>
Allow from 127.0.0.1
+
+ AuthType Basic
+ AuthName "Employee Login"
+ AuthBasicProvider file
+ AuthUserFile /etc/apache2/.htpasswd
+ Require valid-user
</Proxy>
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
+ ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://127.0.0.1:8009/$1$2
+ ProxyPassMatch ^/(.+\.cfchart)(/.*)?$ ajp://127.0.0.1:8009/$1$2
+ ProxyPassMatch ^/(.+\.cfml)(/.*)?$ ajp://127.0.0.1:8009/$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/
+ ProxyPassReverse / ajp://127.0.0.1:8009/
</IfModule>



=== modified file '/etc/apache2/sites-available/000-default.conf'
--- /etc/apache2/sites-available/000-default.conf 2014-10-10 00:12:20 +0000
+++ /etc/apache2/sites-available/000-default.conf 2014-10-10 00:31:59 +0000
@@ -26,6 +26,13 @@
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
+ <Directory /var/www/html>
+ AuthType Basic
+ AuthName "Employee Login"
+ AuthBasicProvider file
+ AuthUserFile /etc/apache2/.htpasswd
+ Require valid-user
+ </Directory>
</VirtualHost>

使用 htpasswd 程序,.htpasswd在中建立一個檔案/etc/apache2。進行調整。

編輯/opt/railo/tomcat/config/server.xml

=== modified file '/opt/railo/tomcat/config/server.xml'
--- /opt/railo/tomcat/config/server.xml 2014-10-10 00:34:48 +0000
+++ /opt/railo/tomcat/config/server.xml 2014-10-10 00:36:33 +0000
@@ -89,7 +89,7 @@
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
+ <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" tomcatAuthentication="false" />
+ <Connector port="8010" protocol="AJP/1.3" tomcatAuthentication="false" secure="true" scheme="https"/>

<!-- An Engine represents the entry point (within Catalina) that processes -->

重新啟動 Railo/Tomcat:

/opt/railo/railo_ctl restart

現在,Railo 應該將基本驗證使用者名稱放入 cgi.remote_user 中。我想我可能必須嘗試將一些內容複製到 localconfig/application.cfm 中的#REMOTE_USER#。但這似乎已經是同一件事了。連接埠 8010 上的第二個 AJP 連接器用於代理 Apache 中啟用 SSL 的虛擬主機。因此,如果您有啟用 SSL 的虛擬主機,請代理到連接埠 8010 而不是 8009。

相關內容