Nginx 将我的请求传递给默认或本地地址

Nginx 将我的请求传递给默认或本地地址

NGINX 配置有两个问题。
我尝试设置prestashopCentOS 7Nginx根据本仪器我在 Prestashop 论坛上发现类似的东西。nginx.config 文件如下:

    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    events {
        worker_connections 1024;
}
http {
  client_header_timeout 300;
  client_body_timeout 300;
  fastcgi_read_timeout 300;
  client_max_body_size 32m;
  fastcgi_buffers 8 128k;
  fastcgi_buffer_size 128k;
  map $http_upgrade $connection_upgrade {
      default upgrade;
      ''      close;
    }
    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;
    tcp_nodelay         on;
    keepalive_timeout   6500;
    types_hash_max_size 3048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include /etc/nginx/conf.d/*.conf;
    include nginx-prestashop.conf;
}

并且 nginx-prestashop.conf 文件是:

upstream php-fpm {
    server 127.0.0.1:9000; #unix:/run/php-fpm/www.sock;
}
server {
    listen 0.0.0.0:80;
    root /var/www/html/prestashop;
    index  index.php index.html index.htm;
    server_name example.com www.example.com;
    server_name_in_redirect off;
    error_log /var/log/nginx/error.log;
    location / {
    rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
    rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$     /img/p/$1/$1$2.jpg last;
    rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$     /img/p/$1/$2/$1$2$3.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-    9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
    rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
    rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
    rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last;
    rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
    try_files $uri $uri/ /index.php?$args;        
    }
    location ~ \.php$ {
    try_files  $uri =404;
    fastcgi_index            index.php;
    fastcgi_pass             php-fpm;
    include                  fastcgi_params;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
    }
server {
  listen 0.0.0.0:443;
  server_name example.com www.example.com;
  server_tokens off; 
  error_log /var/log/nginx/error.log;
  server_name_in_redirect off;
  ssl on;
  ssl_certificate /etc/nginx/sslnginx.crt;
  ssl_certificate_key /etc/nginx/sslnginx.key;
  ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-    SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 5m;
  location / {
     proxy_redirect http://127.0.0.1:80/ $scheme://$host:443/;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection $connection_upgrade;
 }
 location ~ /\.ht {
     deny all;
 }
}

当我尝试的时候http://www.example.com它将我重定向到本地主机/index.php?当我尝试https://www.example.com/它带我进入 NGINX 默认页面,该页面位于/usr/共享/nginx/html/当我尝试洞察服务器时,我遇到了连接被拒绝消息。
我删除了默认配置。
我找不到原因。

相关内容