Nginx Rule for Rails Application

Use following code for setting up Nginx for rails.

http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;</code>

log_format  main  '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

# Timeouts
client_body_timeout   5;
client_header_timeout 5;
keepalive_timeout     55;
send_timeout          5;

upstream mongrel_cluster {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen       80;
server_name  localhost.localdomain;
#charset koi8-r;
#access_log  logs/host.access.log  main;

#for images routing
location ~* ^/(images|stylesheets|javascripts).+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/html/Projects/Project_Name/public;
}
# concurs with nginx's one

location  / {
proxy_pass	http://mongrel_cluster;
#Fix for host name and redirection to domain

}

}

<code>

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.