nginxでSSLを設定するサンプル

2018年6月27日

サンプル:
server {
listen 443;
server_name abc.arkgame.com;

root /usr/share/nginx/www;
index index.php index.html index.htm;

ssl on;
ssl_certificate /etc/ssl/ssl-cert.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert.key;

ssl_session_timeout 5m;

ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;

location / {
try_files $uri $uri/ /index.html;

root /usr/share/nginx/www;
index index.php;
if (-f $request_filename) {
expires 50d;
break;
}
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}