Last active
August 29, 2020 14:23
-
-
Save amanjuman/e95ca524afae3fff4d5a73ea976d9558 to your computer and use it in GitHub Desktop.
Magento 2.x Nginx Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream fastcgi_backend | |
{ | |
server unix:/run/php/php7.2-fpm.sock; | |
} | |
server | |
{ | |
listen 80; | |
listen [::]:80; | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
server_name yourdomain.com www.yourdomain.com; | |
http2_push_preload on; | |
# HTTP to HTTPS redirection | |
if ($scheme != "https") | |
{ | |
return 301 https://$host$request_uri; | |
} | |
# Max Upload Size | |
client_max_body_size 1024M; | |
ssl on; | |
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; | |
ssl_trusted_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; | |
set $MAGE_ROOT /var/www/yourdomain.com; | |
set $MAGE_MODE developer; | |
# fastcgi_split_path_info ^(.+?\.php)(/.*)$; | |
include /var/www/yourdomain.com/nginx.conf.sample; | |
# Nginx Logging | |
access_log /var/log/nginx/yourdomain.com-access.log; | |
error_log /var/log/nginx/yourdomain.com-error.log warn; | |
# Disable Hidden FIle Access Except Lets Encrypt Verification | |
location ~ /\.well-known | |
{ | |
allow all; | |
} | |
# Robot Text Logging Off | |
location = /robots.txt | |
{ | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
# Fav ICON Disable | |
location = /favicon.ico | |
{ | |
log_not_found off; | |
access_log off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment