Redirecting any URI to a unique one

Hi,

I have a website, let’s call it www.mysite.com

On this website, I have a servlet running on tomcat at:
http://127.0.0.1:8080/servlet/service1

From the outside world I want people to access that servlet using the
following URL:
http://servlet.mysite.com

Currently in my nginx conf file I have:

server {
server_name servlet.mysite.com;

location / {
proxy_pass http://127.0.0.1:8080/servlet/service1;
}
}

The problem is that if anyone enters a URL such as
http://servlet.mysite.com/somestuff, Tomcat spits back an ugly 404
page. So I would like that whatever request comes in, tomcat only sees
http://servlet.mysite.com, and thus serves the only servlet I have
available.

Should I use a rewrite for that? Am I doing it the correct way? I have
tried a few things but they all failed, the page couldn’t load
anymore.

I am advancing a bit.

If I enter http://servlet.mysite.com, I get the servlet.

If I enter http://servlet.mysite.com/whatever, for some magical
reason, I get redirected with: http://servlet.mysite.com/index.jsp and
Firefox display that it failed to load the page.

I don’t know who is appending this index.jsp, it is certainly not me.


server {
listen 80;
server_name servlet.mysite.com;

error_log /usr/local/nginx/logs/servlet.log notice;

location / {

rewrite /.+ / break;

root      /usr/local/tomcat-4.1/webapps/servlet/WEB-INF/classes;
index     index.html;

proxy_redirect      off;

proxy_set_header    X-Real-IP $remote_addr;
proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header    Host $http_host;

proxy_pass http://127.0.0.1:8080/servlet/service1;

} # End of the location /
} # End of server

Okay I got it working, I had to append the “last” flag instead of
“break”. But I don’t understand the difference between the two, the
wiki is not crystal clear about that. Does anyone have a good
explanation or can redirect me to an equivalent apache one?

Actually this is the full error message:

Too many redirects occurred trying to open
http://sogenactif.railsbuntu.ath.cx/index.jsp”. This might occur if
you open a page that is redirected to open another page which then is
redirected to open the original page.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs