Skip to content

Instantly share code, notes, and snippets.

@Pelirrojo
Created August 15, 2017 17:34
Show Gist options
  • Save Pelirrojo/395ff527c555d26cc15000d2cf12d435 to your computer and use it in GitHub Desktop.
Save Pelirrojo/395ff527c555d26cc15000d2cf12d435 to your computer and use it in GitHub Desktop.
NGINX Configuration for Magento@2.1.8 SITE with SSL, http->https redirection
# Based in:
# https://www.rosehosting.com/blog/magento-2-with-redis-varnish-and-nginx-as-ssl-termination/
upstream fastcgi_backend {
server unix:/run/php/php7.0-fpm.sock;
}
server {
listen 80;
server_name www.yoursite.com;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 http2 ssl;
server_name www.yoursite.com;
set $MAGE_ROOT /var/www/magento;
set $MAGE_MODE production;
ssl_certificate /etc/ssl/path/to/certificate.cer;
ssl_certificate_key /etc/ssl/path/to/certificate.key;
access_log /var/log/nginx/yoursite-access.log;
error_log /var/log/nginx/yoursite-error.log;
include /var/www/magento/nginx.conf.sample;
}
@Pelirrojo
Copy link
Author

Only replace:

  • cert paths
  • www.yoursite.com for your own domain
  • Create and check the logs path
  • Ensure that the nginx.conf.sample it's included with your distro

Tested on AWS EC2 Ubuntu 16.04

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