VPS侦探论坛

 找回密码
 注册
查看: 2980|回复: 2

这个反代配置那里有问题吗,为什么会导致nginx不能开机自启

[复制链接]
发表于 2019-7-4 17:27:45 | 显示全部楼层 |阅读模式

这个配置是我在/usr/local/nginx/conf/example里面看到的,我只修改了server_name和proxy_pass部分


之前在一台1G1C的centos7小鸡上测试是没问题,VPS重启后访问下载都可以


今天在一台512m的debian9小鸡上配置好,VPS重启后nginx总是无法启动,必须手动启动下才可以


但是如果删掉443模块的所有proxy相关内容,重启后nginx就可以启动了


话说这是那里问题呢?小鸡配置不够,还是debian9问题,还是我反代配置那里没写好?


  1. server {
  2.         listen 80;
  3.         #listen [::]:80;
  4.         server_name example.com www.example.com;

  5.         #如果需要http 301跳转到 https 需要将下面行前面的 # 注释去掉,并重载nginx
  6.         #return 301 https://$host$request_uri;

  7.         location / {
  8.             proxy_pass http://127.0.0.1:3000;
  9.             proxy_http_version    1.1;
  10.             proxy_cache_bypass    $http_upgrade;
  11.             proxy_set_header Upgrade            $http_upgrade;
  12.             proxy_set_header Connection         "upgrade";
  13.             proxy_set_header Host               $host;
  14.             proxy_set_header X-Real-IP          $remote_addr;
  15.             proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
  16.             proxy_set_header X-Forwarded-Proto  $scheme;
  17.             proxy_set_header X-Forwarded-Host   $host;
  18.             proxy_set_header X-Forwarded-Port   $server_port;
  19.         }

  20.         access_log off;
  21. }

  22. server {
  23.         listen 443 ssl http2;
  24.         #listen [::]:443 ssl http2;
  25.         server_name example.com www.example.com;

  26.         ssl_certificate /usr/local/nginx/conf/ssl/example.com.crt;
  27.         ssl_certificate_key /usr/local/nginx/conf/ssl/example.com.key;
  28.         ssl_session_timeout 5m;
  29.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  30.         ssl_prefer_server_ciphers on;
  31.         ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  32.         ssl_session_cache builtin:1000 shared:SSL:10m;
  33.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  34.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

  35.         location / {
  36.             proxy_pass http://127.0.0.1:3000;
  37.             proxy_http_version    1.1;
  38.             proxy_cache_bypass    $http_upgrade;
  39.             proxy_set_header Upgrade            $http_upgrade;
  40.             proxy_set_header Connection         "upgrade";
  41.             proxy_set_header Host               $host;
  42.             proxy_set_header X-Real-IP          $remote_addr;
  43.             proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
  44.             proxy_set_header X-Forwarded-Proto  $scheme;
  45.             proxy_set_header X-Forwarded-Host   $host;
  46.             proxy_set_header X-Forwarded-Port   $server_port;
  47.         }

  48.         access_log off;
  49. }
复制代码


美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2019-7-5 08:34:31 | 显示全部楼层


配置文件上看是没问题的,不好确定什么原因
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2019-7-5 13:10:18 | 显示全部楼层

licess 发表于 2019-7-5 08:34
配置文件上看是没问题的,不好确定什么原因

今天换centos7正常了

之前debian9试了两次重新部署环境都不行
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-22 15:25 , Processed in 0.026830 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表