Вот мой общий конфиг по умолчанию для моего сайта.Мой wordpress находится внутри подкаталога под названием blog.
Использование php 7.2 с установленной fpm.
Я пробовал несколько блоков местоположения для подкаталога, и я либо получаю то, что я в настоящее время получаю с моей конфигурацией, перенаправление.Или я получу сообщение об ошибке 403.
NGINX Error Вывод из журналов (он пытается загрузить материал / static / xxx из моего главного каталога, что не должно происходить) [Кажется, он не пытается загрузить индекс.php в папке blogs]:
2019/02/25 19:43:22 [error] 5026#0: *28577883 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: www.xx.com, request: "GET /blog/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xx.com"
2019/02/25 19:43:22 [error] 5026#0: *28577884 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: www.xx.com, request: "GET /blog/static/js/webim.config.js HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xx.com", referrer: "https://www.xx.com/blog/"
2019/02/25 19:43:22 [error] 5026#0: *28577885 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: www.xx.com, request: "GET /blog/static/js/websdk.shim.js HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xx.com", referrer: "https://www.xx.com/blog/"
2019/02/25 19:43:22 [error] 5026#0: *28577883 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: www.xx.com, request: "GET /blog/static/js/webim.config.js HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xx.com", referrer: "https://www.xx.com/blog/"
2019/02/25 19:43:22 [error] 5026#0: *28577883 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: x.x.x.x, server: www.xx.com, request: "GET /blog/static/js/websdk.shim.js HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xx.com", referrer: "https://www.xx.com/blog/"
Вот моя конфигурация nginx:
(сайт заблокирован)
worker_processes 4;
error_log /usr/local/nginx/logs/error.log;
pid /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name www.xx.com xx.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name www.xx.com;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
access_log /usr/local/nginx/logs/xx.log;
ssl_certificate /usr/local/nginx/cert/XXXX.pem; XX
ssl_certificate_key /usr/local/nginx/cert/XXXX.key; XX
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers XX
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
root /html/pc;
if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)"){
root /html/wap;
}
index index.html index.php;
try_files $uri $uri/ /index.html;
}
location /blog {
root /html;
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php;
}
location ~ .php$ { ## Execute PHP scripts
# if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
и когда я использую это местоположениеБлок для / блога я получаю 403 Ошибка авторизации
location /blog {
alias /html;
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php;
}