Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

PSGINginx

Wes edited this page May 20, 2014 · 1 revision

Nginx Overview

Nginx acts as a proxy to a native running PSGI application. It requires that either plackup, starman or some other PSGI handler is running behind the scenes.

Plack

  1. start plackup
$ sudo plackup /opt/cif/bin/cif.psgi --path /api
HTTP::Server::PSGI: Accepting connections at http://0:5000/

Starman

  1. start starman

Configuration

  1. configure /etc/nginx/sites-enabled/cif.conf
server {
    server_name   myapp.example.com;
    listen 80;
    location /api {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_pass http://localhost:5000;
    }
}
  1. restart nginx
  2. ping the interface
$ curl -w "\n" -X GET 'http://localhost/api/_ping?token=1234'
{"timestamp":[1400585768,265584]}

References

Clone this wiki locally