Skip to content

Instantly share code, notes, and snippets.

@mabuak
Created May 28, 2018 01:44
Show Gist options
  • Save mabuak/d1be4fd0a63b1a16bfda79ccf10d5915 to your computer and use it in GitHub Desktop.
Save mabuak/d1be4fd0a63b1a16bfda79ccf10d5915 to your computer and use it in GitHub Desktop.
Install ssl for nginx localhost
# Open terminal and paste this command
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
# Add this in you nginx config
server {
listen 443 ssl;
root /home/projects/lara;
index index.html index.htm index.php;
server_name projects.loc;
ssl on;
ssl_certificate /etc/nginx/conf.d/localhost.crt;
ssl_certificate_key /etc/nginx/conf.d/localhost.key;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /orpm {
alias /home/projects/lara/orpm/public;
try_files $uri $uri/ @orpm;
location ~ \.php$ {
fastcgi_keep_conn on;
fastcgi_pass upstream;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
location @orpm {
rewrite /orpm/(.*)$ /orpm/index.php?/$1 last;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass upstream;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment