Last active
July 3, 2018 08:23
-
-
Save zernel/e052cb5762a6f56ea2fc6c3af8e2eca2 to your computer and use it in GitHub Desktop.
Nginx Conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream my_app { | |
# server unix:///apps/my_app/tmp/sockets/puma.sock fail_timeout=0; | |
server unix:///apps/my_app/tmp/sockets/puma.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name my_appms.example.com; | |
root /apps/my_app/public; | |
location ~ ^/assets/ { | |
root /apps/my_app/public; | |
expires max; | |
gzip_static on; | |
gzip_vary on; | |
add_header Cache-Control public; | |
} | |
location / { | |
proxy_pass http://my_app; | |
proxy_set_header Host $host; | |
proxy_set_header Origin https://$host; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
# 用于微信认证 | |
location ~ ^/MP_verify_LKAhNLWLv87Zym2T.txt { | |
root /apps/my_app/public; | |
} | |
location ~ ^/(500|404|422).html { | |
root /apps/my_app/public; | |
} | |
error_page 500 502 503 504 /500.html; | |
error_page 404 /404.html; | |
error_page 422 /422.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
# 开启gzip | |
gzip on; | |
# 启用gzip压缩的最小文件,小于设置值的文件将不会压缩 | |
gzip_min_length 1k; | |
# gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间,后面会有详细说明 | |
gzip_comp_level 5; | |
# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。 | |
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; | |
# 是否在http header中添加Vary: Accept-Encoding,建议开启 | |
gzip_vary on; | |
# 禁用IE 6 gzip | |
gzip_disable "MSIE [1-6]\."; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name static.example.com; | |
root /apps/my_static_pages/; | |
index index.html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment