nginx + Cent OS7上的Node.js显示空白页面或ERR_TOO_MANY_REDIRECTS

时间:2018-04-01 08:54:07

标签: node.js linux nginx centos

症状

我认为我搞砸了我的域/ nginx设置。服务器正常显示70%~60%的时间,但有时会显示空白页面(根本没有html)或ERR_TOO_MANY_REDIRECTS页面。

网址为:sungryeol.com

我已经检查了Google上的Stackoverflow和Node.js + CentOS 7 + nginx设置教程(主要导致数字海洋)

设置

Node.js / Express.js

OS:Cent OS 7(Vultr VPS)

反向代理:nginx

DNS:Namecheap

Namecheap域名设置

Type------------------Host---Value-------------------------------TTL
A Record--------------@------45.32.9.128-------------------------5 min
CNAME Record----------www----sungryeol.com.----------------------5 min
URL Redirect Record---www----http://www.sungryeol.com Unmasked---

sungryeol.com上的点''。由Namecheap UI自动添加。

nginx设置

nginx -t显示配置没有错误。我假设内部设置没有问题。它可以正常使用IP地址但仍然显示来自URL的空白页面或重定向错误:(www).sungryeol.com

/etc/nginx/conf.d

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    ...
}

/etc/nginx/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 {
    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" '
                      '$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;
    include /etc/nginx/sites-available/*.conf;
}

/etc/nginx/sites-available/portfolio.conf

upstream portfolio {
  server 127.0.0.1:3001 max_fails=0 fail_timeout=10s weight=1;
  ip_hash;
  keepalive 512;
}

server
{
  listen 80;
  listen [::]:80 ipv6only=on default_server;
  server_name sungryeol.com www.sungryeol.com;
  keepalive_timeout 10;
  # client_max_body_size 50M;
  index index.html;

  location /
  {
    proxy_pass http://portfolio;
    include /etc/nginx/proxy_params;
  }
}

/etc/nginx/proxy_params

proxy_buffers 16 32k;
proxy_buffer_size 64k;
proxy_busy_buffers_size 128k;
proxy_cache_bypass $http_pragma $http_authorization;
proxy_connect_timeout 59s;
proxy_hide_header X-Powered-By;
proxy_http_version 1.1;
proxy_ignore_headers Cache-Control Expires;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 htt$
proxy_no_cache $http_pragma $http_authorization;
proxy_pass_header Set-Cookie;
proxy_read_timeout 600;
proxy_redirect off;
proxy_send_timeout 600;
proxy_temp_file_write_size 64k;
proxy_set_header Accept-Encoding '';
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host;
proxy_set_header Proxy '';
proxy_set_header Referer $http_referer;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Original-Request $request_uri;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

0 个答案:

没有答案