casualjim
10/12/2011 - 10:20 AM

jettyproxy.conf

upstream jetty {
  server 127.0.0.1:12180;
}

server {
  listen   80;

  server_name  www.api.backchat.io;
  rewrite ^/(.*) http://api.backchat.io/$1 permanent;
}

server {
  listen  80;

  server_name api.backchat.io;

  access_log /var/log/backchat/api.backchat.io-access.log;
  error_log /var/log/backchat/api.backchat.io-error.log;

  root   /var/lib/backchat/webapp;

  gzip_static on;
  gzip_vary on;

  try_files $uri/index.html $uri.txt $uri.html $uri @app;

  location @app {
    proxy_buffering   on;
    proxy_pass        http://jetty;
    proxy_redirect    off;
    proxy_set_header  Host             $http_host;
    proxy_set_header  X-Real-IP        $remote_addr;
    proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_read_timeout  5m;
  }

}

server {
  listen   443 ssl;

  ssl    on;
  ssl_certificate      /etc/ssl/certs/wildcard.backchat.io.combined.crt;
  ssl_certificate_key  /etc/ssl/private/wildcard.backchat.io.nopass.key;

  server_name api.backchat.io;

  access_log /var/log/backchat/api.backchat.io-access.log;
  error_log /var/log/backchat/api.backchat.io-error.log;

  root   /var/lib/backchat/webapp;

  gzip_static on;
  gzip_vary on;

  try_files $uri/index.html $uri.txt $uri.html $uri @app;
  

  location @app {
    proxy_buffering     on;
    proxy_pass          http://jetty;
    proxy_redirect      off;
    proxy_set_header    Host             $http_host;
    proxy_set_header    X-Real-IP        $remote_addr;
    proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto https;
    proxy_read_timeout  5m;
  }

}

server {
  listen   443;
  server_name  www.api.backchat.io;
  rewrite ^/(.*) https://api.backchat.io/$1 permanent;
}