Instantly share code, notes, and snippets.

What would you like to do?
wordpress local nginx setup with https
#this creates generic ssl certs (will be unsafe, but usuable for local) for any local servers that use ssl_certificate in their nginx conf
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key
openssl rsa -in -out myssl.key
echo "Generating certificate..."
openssl x509 -req -days 365 -in myssl.csr -signkey myssl.key -out myssl.crt
echo "Copying certificate (myssl.crt) to /etc/ssl/certs/"
mkdir -p /etc/ssl/certs
cp myssl.crt /etc/ssl/certs/
echo "Copying key (myssl.key) to /etc/ssl/private/"
mkdir -p /etc/ssl/private
cp myssl.key /etc/ssl/private/
##this file uses a local wp install with childthemes and https on nginx/php-fpm
#goes in sites-available and sites-enabled
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/myssl.crt;
ssl_certificate_key /etc/ssl/private/myssl.key;
server_name *;
root /Users/benfausch/sites/integramed-wordpress-multisite;
error_log /usr/local/etc/nginx/logs/phpmyadmin.error.log;
access_log /usr/local/etc/nginx/logs/phpmyadmin.access.log main;
# deny access to hidden files
rewrite /\. /THROW_EXPLICIT_404 break;
# set index priority
index index.php index.html index.htm;
# forward php requests
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
# include /usr/local/etc/nginx/conf.d/php-fpm;
# Wordpress /index.php redirect
location / {
try_files $uri $uri/ /index.php?$args;
# Use Prod upload folder if local file doesn't exist
location /wp-content/uploads {
try_files $uri $uri/ @produploads;
location @produploads {
rewrite (.*)$1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment