Nginx 不记录 https / :443 请求

Nginx 不记录 https / :443 请求

我正在尝试使用 https 配置服务器,但出于某种原因,请求似乎根本没有到达 nginx。我一切正常,但一旦我启用 ssl,它就会给我一个不会接受端口 443 上的任何请求(连接超时)的提示。有人知道我该如何开始调试这个问题吗?我使用的是在以前的服务器上使用过的所有相同逻辑。

Nginx.conf:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    port_in_redirect off;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

conf.d 中的 domain.conf:

   server {
  listen 80;      
  server_name domain.com;
  location / {
    rewrite ^ https://$server_name$request_uri? permanent;   
  }
}                  

server {         
  listen 443; 
  server_name domain.com;
  root /var/www/;
  ssl on;
  ssl_certificate /etc/ssl/domain.com.combinded.crt;
  ssl_certificate_key /etc/ssl/domain.com.key;
  index index.html index.htm index.php;


  location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
  }

  location ~ \.php$ {
    fastcgi_intercept_errors on;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
  }

  # BEGIN W3TC Page Cache cache
  location ~ /wp-content/w3tc/pgcache.*html$ {
    add_header Vary "Accept-Encoding, Cookie";
  }
  location ~ /wp-content/w3tc/pgcache.*gzip$ {
    gzip off;
    types {}
    default_type text/html;
    add_header Vary "Accept-Encoding, Cookie";
    add_header Content-Encoding gzip;
  }
  # END W3TC Page Cache cache
  # BEGIN W3TC Browser Cache
  gzip on;
  gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
  location ~ \.(css|js|htc)$ {
  }
  location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
  }
  location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
  }
  # END W3TC Browser Cache
  # BEGIN W3TC Page Cache core
  rewrite ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 last;
  set $w3tc_rewrite 1;
  if ($request_method = POST) {
    set $w3tc_rewrite 0;
  }
  if ($query_string != "") {
    set $w3tc_rewrite 0;
  }
  if ($http_host !~ "XX.XXX.XX.XX") {
    set $w3tc_rewrite 0;
  }
  set $w3tc_rewrite3 1;
  if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php)") {
    set $w3tc_rewrite3 0;
  }
  if ($request_uri ~* "(wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") {
    set $w3tc_rewrite3 1;
  }
  if ($w3tc_rewrite3 != 1) {
    set $w3tc_rewrite 0;
  }
  if ($http_cookie ~* "(comment_author|wp\-postpass|wordpress_\[a\-f0\-9\]\+|wordpress_logged_in)") {
    set $w3tc_rewrite 0;
  }
  if ($http_user_agent ~* "(W3\ Total\ Cache/0\.9\.2\.4)") {
    set $w3tc_rewrite 0;
  }
  set $w3tc_ua "";
  set $w3tc_ref "";
  set $w3tc_ssl "";
  set $w3tc_enc "";
  if ($http_accept_encoding ~ gzip) {
    set $w3tc_enc _gzip;
  }
  set $w3tc_ext "";
  if (-f "$document_root/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl.html$w3tc_enc") {
    set $w3tc_ext .html;
  }
  if ($w3tc_ext = "") {
    set $w3tc_rewrite 0;
  }
  if ($w3tc_rewrite = 1) {
    rewrite .* "/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl$w3tc_ext$w3tc_enc" last;
  }
  # END W3TC Page Cache core

}

答案1

在您的块中,如果文件location ~ \.php$中尚不存在以下行,请包含以下行...fastcgi_params

fastcgi_param HTTPS on;

相关内容