Skip to content

Instantly share code, notes, and snippets.

@pacojp
Last active December 18, 2015 04:08
Show Gist options
  • Save pacojp/5722674 to your computer and use it in GitHub Desktop.
Save pacojp/5722674 to your computer and use it in GitHub Desktop.
user nginx;
worker_processes 3;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format backend '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';
access_log /var/log/nginx/access.log main;
# バージョン番号を表示しない
server_tokens off;
# リダイレクトがかかった際にポート番号を含めない(リバースする際にポート番号を外す)
port_in_redirect off;
# server_nameに正規表現等を使った場合にlocationヘッダがそのまんまになるので
# offで設定する(Hostヘッダから使われる)
server_name_in_redirect off;
# デフォルトは1M
client_max_body_size 20M;
sendfile on;
tcp_nopush off;
keepalive_timeout 0;
#gzip on;
#gzip_http_version 1.0;
#gzip_vary on;
#gzip_comp_level 1;
# gzip圧縮対象の最小サイズ
#gzip_min_length 1024;
# 静的圧縮ファイルの転送を有効化
#gzip_static on;
#gzip_types text/plain text/xml text/css text/javascript
# application/xhtml+xml application/xml
# application/rss+xml application/atom_xml
# application/javascript application/x-javascript
# application/x-httpd-php;
#gzip_disable "MSIE [1-6]\.";
#gzip_disable "Mozilla/4";
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=one:4m max_size=50m inactive=120m;
proxy_temp_path /var/tmp/nginx;
proxy_cache_key "$scheme://$host$request_uri";
proxy_cache_use_stale timeout invalid_header http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_cache_lock_timeout 5s;
proxy_connect_timeout 5;
proxy_send_timeout 10;
proxy_read_timeout 120;
proxy_set_header Host $http_host;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
# 上でhttps -> http なので気にしない、、、
# ってかwordpressがredirect loop するから外す、、、
#proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Pingback;
proxy_hide_header X-Powered-By;
proxy_hide_header Etag;
proxy_hide_header Vary;
upstream phpfpm {
server unix:/var/run/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment