Skip to content

Instantly share code, notes, and snippets.

@hipertracker
Created October 20, 2009 12:05
Show Gist options
  • Select an option

  • Save hipertracker/214210 to your computer and use it in GitHub Desktop.

Select an option

Save hipertracker/214210 to your computer and use it in GitHub Desktop.
NGinx -> TorqueBox
/etc/hosts:
127.0.0.2 homepage jboss_server
127.0.0.4 mydomain
NGINX:
/etc/nginx/sites-enabled/mydomain.conf:
server {
listen mydomain:80;
server_name mydomain;
location / {
if (-f $request_filename) {
access_log off;
expires 30d;
break;
}
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_set_header "ENABLE_X_ACCEL_REDIRECT" "true";
proxy_pass http://homepage:8080;
}
}
TEST
Starting JBoss:
$ $TORQUEBOX_HOME/jboss/run.sh -c web -b jboss_server
$ elinks http://jboss_server:8080
returns error404, but it is fine because I removed root.war file
$ elinks http://homepage:8080
works fine, it opens Ruby on Rails application
$ elinks http://mydomain
returns error404. It looks like it opens http://127.0.0.2:8080
or http://jboss_server:8080.. (JBoss distinguish between http://homepage:8080
and http://127.0.0.2:8080 even if it is the same IP).
@nurettin
Copy link

nurettin commented Mar 1, 2013

Nowadays even this barebones nginx.conf works.

events {

}

http {
  upstream torquebox {
    server 127.0.0.1:8080;
  }

  server {
    location / {
      proxy_pass http://torquebox;
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment