Created
March 29, 2019 12:55
-
-
Save bitkidd/a996eb13046f856b7259f660338b3fb7 to your computer and use it in GitHub Desktop.
VestaCP (Nginx + Php-fpm) force WordPress HTTPS
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 { | |
listen %ip%:%web_ssl_port% http2; | |
server_name %domain_idn% %alias_idn%; | |
root %docroot%; | |
index index.php index.html index.htm; | |
access_log /var/log/nginx/domains/%domain%.log combined; | |
access_log /var/log/nginx/domains/%domain%.bytes bytes; | |
error_log /var/log/nginx/domains/%domain%.error.log error; | |
ssl on; | |
ssl_certificate %ssl_pem%; | |
ssl_certificate_key %ssl_key%; | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ { | |
expires max; | |
} | |
location ~ [^/]\.php(/|$) { | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
if (!-f $document_root$fastcgi_script_name) { | |
return 404; | |
} | |
fastcgi_pass %backend_lsnr%; | |
fastcgi_index index.php; | |
include /etc/nginx/fastcgi_params; | |
} | |
} | |
location /error/ { | |
alias %home%/%user%/web/%domain%/document_errors/; | |
} | |
location ~* "/\.(htaccess|htpasswd)$" { | |
deny all; | |
return 404; | |
} | |
#Yoast SEO Sitemaps | |
location ~ ([^/]*)sitemap(.*).x(m|s)l$ { | |
## this redirects sitemap.xml to /sitemap_index.xml | |
rewrite ^/sitemap.xml$ /sitemap_index.xml permanent; | |
## this makes the XML sitemaps work | |
rewrite ^/([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 last; | |
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last; | |
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; | |
} | |
#include %home%/%user%/conf/web/nginx.%domain%.conf*; | |
include %home%/%user%/web/%domain%/public_html/*.conf; | |
} |
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 { | |
listen %ip%:%web_port%; | |
server_name %domain_idn% %alias_idn%; | |
root %docroot%; | |
location / { | |
rewrite ^(.*) https://%domain_idn%$1 permanent; | |
} | |
include %home%/%user%/conf/web/nginx.%domain%.conf*; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment