I've been trying to set up nginx as a proxy to jetty. I have one laptop running ubuntu server. Now I made jetty working at localhost:8080 and it serves the home page for the app at http://192.168.1.5:8080/my-webapp-0.1.0-standalone/
.
I configured nginx like this (I adapted it from this page):
server {
listen 80;
server_name nomilkfor.me;
rewrite ^(.+?)/?$ http://nomilkfor.me$1 permanent;
}
server {
listen 80;
server_name www.nomilkfor.me;
root /usr/share/nginx/html;
location / {
try_files $uri @my-webapp;
}
location @my-webapp {
proxy_pass http://localhost:8080;
}
}
And I can connect to nginx from my home network and I see the nginx welcome screen.
I also tried $ sudo netstat -tanpl|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3264/nginx: worker
and I see that nginx is listening at port 80.
But when I try to load nomilkfor.me I get "Chrome could not connect to nomilkfor.me" error.
What am I doing wrong?
EDIT
I created a very simple configuration, and this one too servers the index.html
in /usr/share/nginx/
instead of the app through jetty:
server {
listen 80;
server_name nomilkfor.me;
# access_log /var/log/nginx/localhost.access.log;
location / {
proxy_pass http://127.0.0.1:8080;
}
location /html {
root /usr/share/nginx/;
}
}
EDIT 2
It seems that nginx is using another conf file than I think. I added a typo to the conf file /etc/nginx/sites-available/nomilkfor.me
(I removed a closing curly brace) and ran $ nginx -s reload
and it compiled without error and showed the nginx splash page on the browser. Can there be another conf file somewhere? Is there a way to find which conf file nginx is using?
EDIT 3
As per Pazis comment I added root
but not sure exactly where it should be or what it should be. I added a few suggestions. Which one is correct? /usr/share/nginx/html
is where I have the index.html
.
server {
listen 80;
server_name nomilkfor.me;
# root /home/z/jetty/jetty-dist/webapps
root /usr/share/nginx/html;
location / {
proxy_pass http://127.0.0.1:8080;
}
#location /html {
# root /usr/share/nginx/;
}
}
EDIT 4
This is my jetty conf file. It is in /home/z/jetty/jetty-dist/jetty-distribution-9.1.0.v20131115/demo-base/webapps/my-webapp.xml
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration : -->
<!-- + contextPath -->
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/test</Set>
<Set name="war"><Property name="jetty.webapps" default="."/>/my-webapp-0.1.0-standalone.war</Set>