Created
April 18, 2018 07:27
-
-
Save eva-thientran/1888a2d1168cb6b3f1fa32da923dac0e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 tv.molo.vn; | |
index index.php index.html; | |
root /srv/www/tv.molo.vn; | |
add_header "Access-Control-Allow-Origin" *; | |
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD"; | |
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept"; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php { | |
fastcgi_pass unix:/var/run/php-fpm-www.sock; | |
fastcgi_index /index.php; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param APP_ENV {{ APPLICATION_ENV }}; | |
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
#fastcgi_cache MYSTAGING; | |
#fastcgi_cache_valid 200 60m; | |
} | |
} | |
server { | |
listen 443 ssl backlog={{ somaxconn }}; | |
server_name stg.molo.vn ; | |
index index.php index.html; | |
root /srv/www/stg.molo.vn/current/public; | |
#ssl on; | |
#ssl_session_timeout 5m; | |
#ssl_session_cache shared:SSL:10m; | |
#ssl_ciphers RC4:HIGH:!aNULL:!MD5:!kEDH; | |
#ssl_prefer_server_ciphers on; | |
#ssl_certificate /etc/letsencrypt/live/stg.molo.vn/fullchain.pem; | |
#ssl_certificate_key /etc/letsencrypt/live/stg.molo.vn/privkey.pem; | |
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { | |
add_header "" ""; | |
} | |
location ~ "^/pagespeed_static/" { } | |
location ~ "^/ngx_pagespeed_beacon$" { } | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php { | |
# Setup var defaults https://www.lucasoft.info/topics/blog/2/phenomenal-performance-php-nginx-microcaching | |
set $no_cache ""; | |
# If non GET/HEAD, don't cache & mark user as uncacheable for 1 second via cookie | |
if ($request_method !~ ^(GET|HEAD)$) { | |
set $no_cache "1"; | |
} | |
# Drop no cache cookie if need be | |
# (for some reason, add_header fails if included in prior if-block) | |
if ($no_cache = "1") { | |
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/"; | |
add_header X-Microcachable "0"; | |
} | |
# Bypass cache if no-cache cookie is set | |
if ($http_cookie ~* "_mcnc") { | |
set $no_cache "1"; | |
} | |
# Bypass cache if flag is set | |
fastcgi_no_cache $no_cache; | |
fastcgi_cache_bypass $no_cache; | |
fastcgi_pass unix:/var/run/php-fpm-www.sock; | |
fastcgi_index /index.php; | |
include /etc/nginx/fastcgi_params; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param APP_ENV {{ APPLICATION_ENV }}; | |
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
location ~* .(woff|eot|ttf|svg|mp4|webm|jpg|jpeg|png|gif|ico|css|js)$ { | |
access_log off; | |
log_not_found off; | |
expires 365d; | |
fastcgi_hide_header "Set-Cookie"; | |
add_header Cache-Control "public, max-age=315360000"; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment