2

Right now I have my website running on tomcat, www.domain:11000/projectName, I am trying to map when the user enters www.domain:10000 (would do port 80 but my ISP blocks port 80 so I use port forwarding 10000-->80) I created a new site in my site-available with the code:

server{ location / { include /etc/nginx/conf.d/proxy.conf; } }

and inside the proxy.conf file i have:

proxy_set_header Host $host:11000/*projectName*; 

When I try to access the site now it just gives me a 404.

What am I doing wrong? and what can I do to make it work.

RMT
  • 125
  • 2
  • 7

1 Answers1

3

You should carefully read the documentation: http://wiki.nginx.org/JavaServers

After that, you can try this sample virtual host configuration and tweak it as needed in your case:

server {
  listen          80;
  server_name     YOUR_DOMAIN;
  root            /PATH/TO/YOUR/WEB/APPLICATION;

  location / {
    index.jsp;
  }

  location /projectName/ {
    proxy_pass              http://localhost:11000;
    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;
  }
}

If your port 10000 is not redirected to port 80 (I didn't really understand your explanation above), you should replace listen 80; with listen 10000;.

Vladimir Blaskov
  • 6,183
  • 1
  • 27
  • 22
  • Im sorry but when you say virtual host configuration you mean my nginx.conf file? or what (I'm new with this) – RMT Jul 09 '11 at 17:06
  • @rmt, yes, virtual host is the nginx.conf and any other configuration files for nginx to setup web server. – Rihards Jul 09 '11 at 17:23
  • Yes, you could put that in *nginx.conf*, but the Ubuntu-way is to put it in */etc/nginx/sites-available/YOUR_DOMAIN* and link it from */etc/nginx/sites-enabled/YOUR_DOMAIN* with the following command: **ln -s /etc/nginx/sites-available/YOUR_DOMAIN /etc/nginx/sites-enabled/YOUR_DOMAIN** – Vladimir Blaskov Jul 09 '11 at 17:25
  • I have already linked the 2, another thing Ive been googling this for a bit where is the web application default on tomcat 6? – RMT Jul 09 '11 at 17:26
  • @Vladimir Blaskov I did what you have suggested and instead of getting 404 page, I know get 403 (forbidden) – RMT Jul 10 '11 at 02:52
  • That should be coming from your Tomcat server. I suggest that you read the log files - maybe some DirectoryIndex directive is missing and it's returning 403 instead of showing you directory contents. – Vladimir Blaskov Jul 10 '11 at 07:09
  • @Vladimi, I figured it out, what I needed to do was in the proxy pass http://localhost:11000/projectName/ and that works – RMT Jul 15 '11 at 18:56