Created
January 25, 2022 13:24
-
-
Save PhongGCS/abe8c9693b9cca3ab785d999104d7110 to your computer and use it in GitHub Desktop.
wordpress nginx config
This file contains 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
server { | |
# Ports to listen on, uncomment one. | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
# Server name to listen for | |
server_name mmhome.vn; | |
# Path to document root | |
root /var/www/html/web | |
# Paths to certificate files. | |
ssl_certificate /etc/letsencrypt/live/mmhome.vn/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/mmhome.vn/privkey.pem; | |
# File to be used as index | |
index index.php; | |
# Overrides logs defined in nginx.conf, allows per site logs. | |
access_log /sites/mmhome.vn/logs/access.log; | |
error_log /sites/mmhome.vn/logs/error.log; | |
# Default server block rules | |
#include global/server/defaults.conf; | |
# SSL rules | |
#include global/server/ssl.conf; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
root /var/www/html/web | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
} | |
} | |
# Redirect http to https | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name mmhome.vn www.mmhome.vn; | |
return 301 https://mmhome.vn$request_uri; | |
} | |
# Redirect www to non-www | |
server { | |
listen 443; | |
listen [::]:443; | |
server_name www.mmhome.vn; | |
return 301 https://mmhome.vn$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo certbot --nginx -d mmhome.vn -d www.mmhome.vn