hyp*_*jas 1 deployment nginx unicorn
我想在我的nginx和独角兽中激活gzip压缩:
我在config/unicorn.rb的 rails应用程序中有这个:
working_directory "/home/user/project.com/current"
shared_path = '/home/user/project.com/shared'
pid "#{shared_path}/pids/unicorn.pid"
stderr_path "#{shared_path}/log/unicorn.log"
stdout_path "#{shared_path}/log/unicorn.log"
listen '/tmp/unicorn.project.sock'
worker_processes 2
timeout 30
Run Code Online (Sandbox Code Playgroud)
我在我的rails app中的nginx.conf中有这个:
upstream unicorn {
server unix:/tmp/unicorn.project.sock fail_timeout=0;
}
server {
listen 80 default;
root ~/project.com/current/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
}
Run Code Online (Sandbox Code Playgroud)
如何启用此配置,如:
gzip_static on;
expires max;
add_header Cache-Control public;
Run Code Online (Sandbox Code Playgroud)
谢谢!
server { }在您的配置中添加到阻止:
location ~ ^/(assets)/ {
root /path/to/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
Run Code Online (Sandbox Code Playgroud)
Checkout Rails指南了解更多信息.
| 归档时间: |
|
| 查看次数: |
2158 次 |
| 最近记录: |