Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Nginx总是落在错误的服务器块上_Php_Nginx_Silex - Fatal编程技术网

Php Nginx总是落在错误的服务器块上

Php Nginx总是落在错误的服务器块上,php,nginx,silex,Php,Nginx,Silex,我有两个不同的域和两个可用的nginx文件。我还添加了符号链接 第一个站点配置,应处理基于Silex的API: server { listen 443 ssl; listen [::]:443 ipv6only=on ssl; server_name bwr.mydomain1.com; root /srv/www/bwr/src; location / { # try to serve file directly, fallback

我有两个不同的域和两个可用的nginx文件。我还添加了符号链接

第一个站点配置,应处理基于Silex的API:

server {
    listen 443 ssl;
    listen [::]:443 ipv6only=on ssl;

    server_name bwr.mydomain1.com;
    root /srv/www/bwr/src;

    location / {
        # try to serve file directly, fallback to front controller
        try_files $uri /index.php$is_args$args;
    }

    # If you have 2 front controllers for dev|prod use the following line instead
    # location ~ ^/(index|index_dev)\.php(/|$) {
    location ~ ^/index\.php(/|$) {
        # the ubuntu default
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        # for running on centos
        #fastcgi_pass   unix:/var/run/php-fpm/www.sock;

        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;

        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Enable the internal directive to disable URIs like this
        # internal;
    }

    #return 404 for all php files as we do have a front controller
    location ~ \.php$ {
        return 404;
    }

    # SSL configuration with letsencrypt
    ssl_certificate "/etc/letsencrypt/live/bwr.mydomain1.com/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/bwr.mydomain1.com/privkey.pem";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
    ssl_prefer_server_ciphers on;


    error_log /var/log/nginx/bwr_error.log;
    access_log /var/log/nginx/bwr_access.log;
}

server {
    listen 80;
    listen [::]:80 ipv6only=on;
    server_name bwr.mydomain1.com;
    return 301 https://$host$request_uri;
}
第二个域仅服务于普通的php网站:

server {
  listen 443 ssl default_server;

  server_name domain2.ch www.domain2.ch;

  root /srv/www/hgtconnect;
  index index.html index.php;

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }

  error_log /var/log/nginx/domain2_error.log;
  access_log /var/log/nginx/domain2_access.log;

    # SSL configuration with letsencrypt
  ssl_certificate "/etc/letsencrypt/live/domain2.ch/fullchain.pem";
  ssl_certificate_key "/etc/letsencrypt/live/domain2.ch/privkey.pem";
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout  10m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
  ssl_prefer_server_ciphers on;
}

server {
  listen 80 default_server;
  server_name domain2.ch www.domain2.ch;
  return 301 https://$host$request_uri;
}
无论何时打开,我都会看到bwr.domain1.com的内容。此外,使用了错误的ssl证书,并且该站点不受信任

谢谢

找到了灵魂。 两个服务器块上均未启用Ipv6。我总是在Ipv6网络中请求页面,因此nginx总是返回到错误的服务器上,因为在那里配置了Ipv6。

找到了解决方案。
两个服务器块上均未启用Ipv6。我总是在Ipv6网络中请求页面,因此nginx总是返回到错误的服务器上,因为在那里配置了Ipv6。

检查nginx错误日志检查nginx错误日志