Skip to content
epicmonkey edited this page Dec 11, 2014 · 2 revisions

For the production environment you may want to setup nginx as a proxy server, however this is totally optional for the development:

upstream app_pepyatka {
    server 127.0.0.1:3000;
}

server {
    listen         80;
    server_name    api.pepyatka.com;
    return         301 https://$server_name$request_uri;
}

server {
    listen 0.0.0.0:443;
    server_name api.pepyatka.com apipepyatka;
    access_log /var/log/nginx/pepyatka.log;

    gzip on;
    gzip_comp_level 6;
    gzip_vary on;
    gzip_min_length  1000;
    gzip_proxied any;
    gzip_buffers 16 8k;

    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ssl on;
    ssl_certificate /etc/nginx/ssl/api.pepyatka.crt;
    ssl_certificate_key /etc/nginx/ssl/api.pepyatka.key;

    location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|files/\
|robots.txt|humans.txt|favicon.ico) {
      root /var/www/pepyatka/public;
      access_log off;
      expires max;
    }

    # disable logging for some `common` files
    # Disable logging for favicon
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    # Disable logging for robots.txt
    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";

      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 X-NginX-Proxy true;

      proxy_pass http://app_pepyatka/;
      proxy_redirect off;
    }
}
Clone this wiki locally