有没有办法使用HTTP代理将Apache连接到Tomcat,以便Tomcat获取正确的传入主机名而不是localhost?我在apache中使用此指令:
ProxyPass /path http://localhost:8080/path
Run Code Online (Sandbox Code Playgroud)
但它来自localhost,当我们在同一台服务器上有一堆站点时,这是无用的.我可以在服务器配置中手动设置主机:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
proxyName="pretend.host" proxyPort="80" />
Run Code Online (Sandbox Code Playgroud)
但这再次不会提供多个站点.而且我不喜欢为每个站点使用不同的内部端口,听起来真的很难看.
我代理它时是否无法转移端口?
(如果你问为什么我不只是使用AJP,答案就是这个错误.我在尝试完全放弃Tomcat和Apache之前我正在尽我所能)
我在http:// localhost:5984 /上运行了apache couchDB ,我需要访问http:// localhost:80/couch /.我需要为此设置反向proxi.需要有关配置设置的帮助.
PS:什么是了解apache的最佳资源?
基本上我的情况是我有一个内部网站,需要一个单一的硬编码用户名和密码才能访问(这不能关闭,只能更改).我出于各种原因通过反向代理公开这个网站(隐藏端口,简化网址,简化NAT等).
但是,我想要做的是能够使用Apache来处理身份验证,以便:
编辑:关于更丰富的身份验证的第二部分已移至新问题
这或多或少是我现在所拥有的:
<VirtualHost *:80>
ServerName sub.domain.com
ProxyPass / http://192.168.1.253:8080/endpoint
ProxyPassReverse / http://192.168.1.253:8080/endpoint
# The endpoint has a mandatory password that I want to avoid requiring users to type
# I.e. something like this would be nice (but does not work)
# ProxyPass / http://username:password@192.168.1.253:8080/endpoint
# ProxyPassReverse / http://username:password@192.168.1.253:8080/endpoint
# Also need to be able to require a password to access proxy for people outside local subnet
# However these passwords will be …Run Code Online (Sandbox Code Playgroud) 我有一个只能通过HTTPS访问的Apache运行.我想从另一个在同一台机器上运行的服务器应用程序提供websockets,但由于客户端无法连接到443以外的另一个端口到我们的服务器,因此需要通过Apache代理这些websocket连接.
现在,我已经安装了mod_proxy并按如下方式配置它:
SSLProxyEngine on
ProxyPass /ws https://127.0.0.1:9001
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我现在可以在我的浏览器中连接到https:// server/ws,但是apache似乎吞下了部分websockets标头,因此真正的websocket连接不起作用.
如何通过Apache服务器完成对websocket连接的隧道连接?
有关背景资料:(底部问题)
我正在尝试连接到一个客户端,该客户端有8台服务器,所有服务器都有唯一的IP地址.客户端在所有服务器上使用相同的SSL证书(例如,cert name == www.all_servers.com).客户端仅允许通过https传入请求.
我正在尝试使用mod_proxy创建一个apache代理,该代理将不同的URI映射映射到不同的服务器.例如:
https://PROXY_SERVER/SERVER1/{REQUEST}
Run Code Online (Sandbox Code Playgroud)
这会将{REQUEST}发送到server1
https://PROXY_SERVER/SERVER2/{REQUEST}
Run Code Online (Sandbox Code Playgroud)
将{REQUEST}发送到server2.到目前为止,非常简单.
在Apache 2.2中,这可以通过使用如下所示的IP地址来实现:
SSLProxyEngine On
ProxyPass /server1 https://1.1.1.1/
ProxyPassReverse /server1 https://1.1.1.1/
ProxyPass /server2 https://1.1.1.2/
ProxyPassReverse /server2 https://1.1.1.2/
Run Code Online (Sandbox Code Playgroud)
这是因为Apache 2.2没有检查证书是否匹配(1.1.1.1!= www.all_servers.com)
但是,在Apache 2.4中,我现在正在获得证书问题(这是正确的).(这个确切的代码适用于apache 2.2框)
[Thu Oct 10 12:01:48.571246 2013] [proxy:error] [pid 13282:tid 140475667224320] (502)Unknown error 502: [client 192.168.1.1:48967] AH01084: pass request body failed to 1.1.1.1:443 (1.1.1.1)
[Thu Oct 10 12:01:48.571341 2013] [proxy:error] [pid 13282:tid 140475667224320] [client 192.168.1.1:48967] AH00898: Error during SSL Handshake with remote server returned by /server1/asd
[Thu Oct 10 12:01:48.571354 …Run Code Online (Sandbox Code Playgroud) 我们目前正在使用Apache 2.2.3和Tomcat 5(嵌入在JBoss 4.2.2中)mod_proxy_jk作为连接器.
有人可以详细说明计算/配置下面的值的正确方法(以及其他可能相关的值).Apache和Tomcat都在不同的机器上运行,并且有大量的ram(每个4gb).
相关的server.xml部分:
<Connector port="8009"
address="${jboss.bind.address}"
protocol="AJP/1.3"
emptySessionPath="true"
enableLookups="false"
redirectPort="8443"
maxThreads="320"
connectionTimeout="45000"
/>
Run Code Online (Sandbox Code Playgroud)
相关的httpd.conf部分:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 0
</IfModule>
Run Code Online (Sandbox Code Playgroud) 我正在使用mod重写来掩盖我的应用程序的上下文根.例如,
RewriteRule ^/directory/(.*) balancer://appcluster/directory/$1 [P]
Run Code Online (Sandbox Code Playgroud)
appcluster看起来像这样:
<Proxy balancer://appcluster>
BalancerMember http://localhost:8080/App route=app_01 keepalive=On loadfactor=1 ttl=300 min=3 smax=5 max=15
ProxySet lbmethod=byrequests stickysession=JSESSIONID|jsessionid timeout=120 nofailover=On
</Proxy>
Run Code Online (Sandbox Code Playgroud)
我需要使用ProxyPassReverse吗?我曾经使用它,因为我的旧网络服务器代码看起来像这样:
ProxyPass /App balancer://appcluster lbmethod=byrequests stickysession=JSESSIONID|jsessionid timeout=120 nofailover=On
ProxyPassReverse /App http://localhost:9013/App
Run Code Online (Sandbox Code Playgroud) 我有一个HTTP Basic安全网站.我用mod_proxy隐藏了一个Tomcat应用服务器.我可以删除HTTP Basic标头吗?Tomcat应用程序读取标头并返回未授权的401.不需要基本身份验证,因为应用程序使用cookie会话.所以我认为删除标题会很好.
DeviceA充当反向代理,应该按如下方式转发请求:
192.168.1.10/DeviceB ==> 192.168.1.20/index.html
192.168.1.10/DeviceC ==> 192.168.1.30/index.html
两个索引文件都位于/ var/www下,并且是静态的"Hello world!" 页面.问题是我无法通过DeviceA访问这些文件,但如果我调用也在DeviceC上运行的测试服务(侦听端口12345),一切正常.
我错了说DeviceB上的Web服务器,如果端口80上有请求,DeviceC应该用index.html响应???
lighttpd.conf DeviceA @ 192.168.1.10 server.modules =("mod_proxy")
proxy.server = (
"/DeviceB" => ( "" => ( "host" => "192.168.1.20", "port" => 80 )),
"/DeviceC" => ( "" => ( "host" => "192.168.1.30", "port" => 80 )),
"/TestService" => ( "" => ( "host" => "192.168.1.30", "port" => 12345 ))
)
Run Code Online (Sandbox Code Playgroud)
lighttpd.conf DeviceB @ 192.168.1.20
server.document-root = "/var/www"
server.port = 80
index-file.names = ( "index.html" )
Run Code Online (Sandbox Code Playgroud)
lighttpd.conf DeviceC @ 192.168.1.30 …
我在tomcat上有一个Web应用程序 http://localhost:8080/WebApp/
我已经配置了Apache 2(mod_proy),因此localhost可以直接访问Web应用程序,并输出端口和名称:例如 http://localhost
<VirtualHost localhost:80>
ProxyPreserveHost On
ProxyPass / http://localhost:8080/WebApp/
ProxyPassReverse / http://localhost:8080/WebApp/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
index.html正确显示http://localhost.但是如果servlet重定向:
@WebServlet(description = "...", urlPatterns = { "/login" })
public class LoginServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
response.sendRedirect("a.html");
}
}
Run Code Online (Sandbox Code Playgroud)
我使用URL http://localhost/login- 我被重定向到http://localhost/WebApp/a.html
如何获得正确的重定向http://localhost/a.html?