wordpress-nginx-main/sites-available/nginx-varnish-nginx.conf
hhftechnologies dd82b3e56c update
2024-09-28 17:48:20 +05:30

82 lines
2.3 KiB
Text

server {
listen 80;
server_name example.com;
# Replace the path with the actual path to WordPress core files
root "/home/username/sites/example.com/public";
index index.php;
# Logs - do check these, if sth goes wrong
access_log /var/log/nginx/example.com-access.log combined buffer=64k flush=5m if=$loggable;
error_log /var/log/nginx/example.com-error.log;
include globals/restrictions.conf;
include globals/assets.conf;
location / {
error_page 418 = @phpfpm;
if ($request_method = POST) { return 418; }
if ($http_cookie ~* "wordpress_logged_in") { return 418; }
if ($http_cookie ~* "comment_") { return 418; }
if ($http_cookie ~* "wp_postpass_") { return 418; }
proxy_pass http://varnish;
include proxy.conf;
}
location @phpfpm {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include "fastcgi.conf";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass fpm;
}
location ~ /wp-admin {
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include "fastcgi.conf";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass fpm;
}
}
}
# To serve requests from Varnish
# Setup Varnish to use 127.0.0.1:82 as backend for this domain
server {
listen 127.0.0.1:82;
server_name example.com;
# Replace the path with the actual path to WordPress core files
root "/home/username/sites/example.com/public";
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include "fastcgi.conf";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass fpm;
}
}