Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

regex - Transparent redirect to port 8080

I have a few web applications available on my server on port 8080.

As some of my users can't reach port 8080 due to their firewall, I'd like to set a redirection on my apache server. Il would like the following URL

http://dev2.test.com/tomcat/somewebapp/restofthepath

to display what is accessible at

http://dev2.test.com:8080/somewebapp/restofthepath

Of course I don't want users typing the first address to see the second one.

I added the following .htaccess file in /var/www :

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(tomcat)
RewriteRule ^/tomcat/(.*)$ http://dev2.test.com:8080/$1 [P,QSA,L]

But I get this error in /var/log/apache2/error.log :

[Tue Oct 09 15:23:06 2012] [error] File does not exist:  proxy:http://dev2.test.com:8080/tomcat/

Could you please tell me what I should do ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should probably be using mod_proxy instead of mod_rewrite.

ProxyPass /tomcat http://dev2.test.com:8000/
ProxyPassReverse /tomcat http://dev2.test.com:8000/

EDIT :

This configuration must be in httpd.conf. It may be in a VirtuaHost section or at the root of the file.

You have to enable mod_proxy. This could be done using

LoadModule  proxy_module         /usr/lib/apache2/modules/mod_proxy.so
LoadModule  proxy_http_module    /usr/lib/apache2/modules/mod_proxy_http.so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...