-
Notifications
You must be signed in to change notification settings - Fork 62
Nginx
gazeldx edited this page Feb 13, 2013
·
14 revisions
这一节的内容不是必须的,因为在上一节我们已经成功的运行了网站。
Nginx作反向代理服务器,是可以提升性能。如果你想提升网站访问速度,就像我的故事网站一样,把Nginx启用了吧!
$ sudo apt-get install nginx
$ cd /etc/nginx
$ vim nginx.conf
在http {...}中加入
upstream mystory_backend {
server unix:/tmp/unicorn.mystory.sock fail_timeout=0;
}
server {
listen 80;
root /root/mystory/public;
server_name yourdomain.com;
#location ~* ^(/assets|/favicon.ico) {
# access_log off;
# expires max;
#}
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering on;
proxy_pass http://mystory_backend;
}
}
将下面的[email protected]改为你的值
$ rvm wrapper [email protected] bootup unicorn
$ sudo service nginx restart
$ cd mystory
$ bootup_unicorn -c config/unicorn.rb -E production -D
参考文章:
http://zhangjian.mystory.cc/notes/390/
http://wiki.ubuntu.org.cn/Nginx
http://ruby-china.org/topics/471