Hi -
This is probably an easy question ... but it's my first time setting up nginx as a proxy in front of Jetty (on Debian), and I'm doing something wrong with my configuration.
Jetty is serving my Java web app correctly, because if I test it with this lengthier alternate notation (which I also used before setting up the nginx proxy), the Java web app login page appears and I can log in:
[code]
http://myhost.com:8080/testapp001.com
[/code]
But when I do the following:
[code]
http://testapp001.com
[/code]
I get the error message:
[code]
403 Forbidden
nginx/0.8.53
[/code]
Here's my nginx.conf and testapp001.com.xml files
[code]
# This file is /etc/nginx/sites-available/testapp001.com
# Source: http://wiki.nginx.org/JavaServers
server {
listen 80;
server_name .testapp001.com;
access_log /var/log/www/testapp001.com/access.log;
error_log /var/log/www/testapp001.com/error.log;
root /opt/jetty/webapps/testapp001.com;
# Note: there is no file called /opt/jetty/webapps/testapp001.com/index.jsp on my system.
# So I was "suspicious" about this location directive below.
# I tried doing a test: I commented it out and restarted nginx and Jetty.
# But navigating to http://testapp001.com still gave the same error message "403 forbidden".
location / {
index index.jsp;
}
location ~ \.do$ {
proxy_pass http://localhost:8080;
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;
}
location ~ \.jsp$ {
proxy_pass http://localhost:8080;
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;
}
location ^~/servlets/* {
proxy_pass http://localhost:8080;
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;
}
}
[/code]
The Java web app's WAR file has been decompressed into a directory in:
[code]
/opt/jetty/webapps/testapp001.com
[/code]
[code]
# This file is /opt/jetty/etc/testapp001.com.xml
# Source: http://wiki.nginx.org/JavaServers
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="configurationClasses">
<Array type="java.lang.String">
<Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
<Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
<Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>
</Set>
<Set name="contextPath">/</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webapps/testapp001.com</Set>
<Set name="virtualHosts">
<Array type="java.lang.String">
<Item>testapp001.com</Item>
</Array>
</Set>
# I commented this part out - because this Java web app actually does not use a database.
# <New id="YOUR_DB_NAME" class="org.mortbay.jetty.plus.naming.Resource">
# <Arg>jdbc/YOUR_DB_NAME</Arg>
# <Arg>
# <New class="org.postgresql.ds.PGConnectionPoolDataSource">
# <Set name="User">postgres</Set>
# <Set name="Password">*****</Set>
# <Set name="DatabaseName">YOUR_DB_NAME</Set>
# <Set name="ServerName">localhost</Set>
# <Set name="PortNumber">5432</Set>
# </New>
# </Arg>
# </New>
</Configure>
[/code]
[code]
# This file is /opt/nginx/conf/nginx.conf
# The correct symlink was also created previously:
# sudo ln -s /etc/nginx/sites-available/testapp001.com /etc/nginx/sites-enabled
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/sites-enabled/*;
}[/code]
After I edit the above files, I do:
[code]
sudo /etc/init.d/nginx restart
sudo /etc/init.d/jetty restart
[/code]
Thanks for any help!
Edited 2 time(s). Last edit at 11/18/2010 03:50PM by StefanScott.