Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WordPress - Nginx Configuration File (with SSL) -->
# @server studio
# @host
# @desc nginx host rules
# @author Julien Le Coupanec <>
# HTTP Server
server {
listen 80;
rewrite ^ https://$server_name$request_uri permanent;
# HTTPS Server
server {
listen 443;
root /var/www;
index index.php;
error_log /var/log/nginx/ crit;
ssl on;
ssl_certificate /etc/nginx/ssl/;
ssl_certificate_key /etc/nginx/ssl/;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # do not use SSLv3 ref: POODLE
client_max_body_size 20M;
location / {
try_files $uri $uri/ /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
location /doc/ {
alias /usr/share/doc/;
autoindex on;
deny all;
location ~/\.ht {
deny all;

if you have listen 443 ssl on; is not necessary
Thanks for your gist =D

Sauraus commented Dec 20, 2016

What about setting $_SERVER['HTTPS'] = 'on' in the wp-config.php file?

sondnm commented Jul 30, 2017

@thiagovsk It's only not required from nginx 0.7.14
I think it should be listen 443 ssl; instead of listen 443; when you are not using ssl on; directive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment