Nginx famous now. We given information for how to host multiple rails site on Nginx. we given the configuration code along with their detailed information.
How to host multiple rails site on Nginx
User following code in Nginx.conf file.. and paste into that file.
#vim /etc/nginx/nginx.conf
02 | include /etc/nginx/mime.types; |
03 | default_type application/octet-stream; |
04 | access_log /var/log/nginx/access.log main; |
07 | upstream mongrel_cluster_example1 { |
13 | upstream mongrel_cluster_example2 { |
20 | include /etc/nginx/conf.d/*.conf; |
24 | server_name example1.com example2.net; |
25 | client_max_body_size 120M ; |
27 | set $myroot /var/www/html; |
28 | if ( $host ~* example1\.com$) { |
29 | set $myroot /home/example1/public; |
32 | if ( $host ~* example2\.net$) { |
33 | set $myroot /home/example2/public; |
38 | 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)$ |
45 | if ( $host ~* example1\.com$) { |
46 | proxy_pass http://mongrel_cluster_example1; |
49 | if ( $host ~* example2\.net$) { |
50 | root /home/rail_project/myproject/public; |
51 | proxy_pass http://mongrel_cluster_example2; |