首页 > 解决方案 > NGINX - 未找到文件

问题描述

我需要有关我的 nginx 配置的帮助。目前我有一个功能齐全的 Nextcloud 实例,可以从子域访问。我使用 wordpress docker 和 manuell install 测试了我的设置,结果相同。

问题在于我的 wordpress 安装,Nginx 将无法访问文件,我无法访问 wordpress UI。这可能与文件权限有关吗?因为错误日志不显示任何文件路径,但 Nginx 运行并且不显示配置错误。

/swag/nginx/error.log入口

2021/09/20 15:33:22 [error] 473#473: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: , server: , request: "GET / HTTP/2.0 ", 上游: "fastcgi://127.0.0.1:9000", 主机: ""

如果我需要提供更多信息/文件,请告诉我!

# REDIRECT WWW TO https://[domain.com]
server {
 listen 80;
 listen 443 ssl http2;
 server_name www.<DOMAIN>; 
 return 301 https://<DOMAIN>$request_uri;
}

# REDIRECT HTTP TRAFFIC TO https://[domain.com]
server {
    listen 80;
    server_name <DOMAIN>; 
    return 301 https://<DOMAIN>$request_uri;
}

# BLOG SITE
server {
 listen 443 ssl http2;
 server_name <DOMAIN>;

## Source: https://github.com/1activegeek/nginx-config-collection
## READ THE COMMENT ON add_header X-Frame-Options AND add_header Content-Security-Policy IF YOU USE THIS ON A SUBDOMAIN YOU WANT TO IFRAME!

##NOTE: The add_header Content-Security-Policy won't work with duckdns since you don't own the root domain. Just buy a domain. It's cheap
## Settings to add strong security profile (A+ on securityheaders.io/ssllabs.com)

add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none; #SET THIS TO index IF YOU WANT GOOGLE TO INDEX YOU SITE!
add_header Content-Security-Policy "frame-ancestors https://*.$server_name https://$server_name"; ## Use *.domain.com, not *.sub.domain.com (*.$server_name) when using this on a sub-domain that you want to iframe!
add_header X-Frame-Options "ALLOW-FROM https://*.$server_name" always; ## Use *.domain.com, not *.sub.domain.com (*.$server_name) when using this on a sub-domain that you want to iframe!
add_header Referrer-Policy "strict-origin-when-cross-origin";

 
 client_max_body_size 0; 
#Manuell install 
 root /mnt/user/appdata/swag/www/wordpress/;
#Docker
#   root /mnt/user/appdata/www/wordpress; 
index index.html index.php;
  
location ~ /\. {
deny all;
} 
location / {
try_files $uri $uri/ /index.php?_url=$uri&$query_string; 
}

 
# PHP
 location ~ \.php$ {
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 # With php7-cgi alone:
 fastcgi_pass 127.0.0.1:9000;
 # With php7-fpm:
 #fastcgi_pass unix:/var/run/php7-fpm.sock;
 fastcgi_index index.php;
 include /etc/nginx/fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


 }
 
 fastcgi_buffer_size 4K;
 fastcgi_buffers 64 4k; 
}

标签: phpwordpressnginx

解决方案


推荐阅读