HTTP ERROR 500-此页面无法使用-如何在NGINX上修复它?

时间:2019-10-26 10:03:31

标签: php ssl nginx cloudflare nginx-config

请告诉我可能是什么问题?

  

HTTP错误500-此页面无法使用-NGINX

我尝试了很多,但是我无法弄清楚。

  

在某些子域上,一切都很好,在某些链接上无法正常工作,只是无法访问页面,而是保留在主页面上


图片-https://imgur.com/0WYoenD.png


Nginx


┌─[root@site]─[/etc/nginx]
└──╼ #nginx -v
nginx version: nginx/1.17.5

PHP


┌─[root@site]─[/etc/nginx]
└──╼ #php -v
PHP 7.4.0RC3 (cli) (built: Oct  8 2019 06:09:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.0RC3, Copyright (c), by Zend Technologies

还安装了7.3和7.1


/etc/nginx/nginx.conf


user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535;

events {
    multi_accept on;
    worker_connections 65535;
}

http {
    charset utf-8;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    server_tokens off;
    log_not_found off;
    types_hash_max_size 2048;
    client_max_body_size 16M;

    # MIME
    include mime.types;
    default_type application/octet-stream;

    # logging
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log warn;

    # SSL
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
    ssl_session_tickets off;

    # Mozilla Modern configuration
    ssl_protocols TLSv1.3;
    ssl_prefer_server_ciphers off;
    ssl_dhparam /etc/ssl/certs/dhparam4096.pem; # openssl dhparam -out /etc/ssl/certs/dhparam4096.pem 4096

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;

    # OCSP Stapling
    #ssl_stapling on;
    #ssl_stapling_verify on;
    resolver 1.1.1.1 1.0.0.1 valid=60s;
    resolver_timeout 2s;

    # load configs
    include /etc/nginx/conf.d/*.conf;
    #include /etc/nginx/sites-enabled/*;
}

/etc/nginx/conf.d/site.site.com.conf

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  # 301 Moved Permanently response.
  # old rule return 301 https://$host$request_uri;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }

  server_name site.site.com;
  set $base /var/www/site.com;
  root $base/site;

  # SSL - cloudflare
  ssl_certificate /etc/nginx/ssl/certs/cert.pem;
  ssl_certificate_key /etc/nginx/ssl/private/key.pem;
  ssl_client_certificate /etc/nginx/ssl/certs/cloudflare.crt;
  ssl_verify_client on;

  # OSCP trust
  ssl_trusted_certificate /etc/nginx/ssl/certs/cert.pem;

  # Security
  #include nginxconfig.io/security.conf;

  # SecureHeader
  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
  add_header X-Frame-Options "SAMEORIGIN" always;
  add_header X-Content-Type-Options "nosniff" always;
  add_header X-XSS-Protection "1; mode=block" always;
  #add_header Referrer-Policy "no-referrer-when-downgrade" always;
  ##add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;

  # index.php
  index index.php;

  # index.php fallback -  try_files $uri $uri/ /index.php?$query_string;
  location / {
    rewrite ^\/(.+)$ /index.php?altum=$1 last;
  }

  # handle .php
  location ~ \.php$ {
    include nginxconfig.io/php_fastcgi71.conf;
  }

  # additional config
  include nginxconfig.io/general.conf;

}

/etc/nginx/nginxconfig.io/security.conf

# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

# . files
location ~ /\.(?!well-known) {
    deny all;
}


/etc/nginx/nginxconfig.io/general.conf

# favicon.ico
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

# robots.txt
location = /robots.txt {
    log_not_found off;
    access_log off;
}

# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
    expires 7d;
    access_log off;
}

# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
    add_header Access-Control-Allow-Origin "*";
    expires 7d;
    access_log off;
}

# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;


/etc/nginx/nginxconfig.io/php_fastcgi.conf

# 404
try_files $fastcgi_script_name =404;

# default fastcgi_params
include fastcgi_params;

# fastcgi settings
fastcgi_pass            unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index           index.php;
fastcgi_buffers         8 16k;
fastcgi_buffer_size     32k;

# fastcgi params
fastcgi_param DOCUMENT_ROOT     $realpath_root;
fastcgi_param SCRIPT_FILENAME   $realpath_root$fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE   "open_basedir=$base/:/usr/lib/php/:/tmp/";

/etc/nginx/nginxconfig.io/php_fastcgi.conf

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M
max_execution_time = 360

0 个答案:

没有答案