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

搬瓦工机场JMS

环境是都是军哥lnmp

这个配置是我在/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 http://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 http://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. }

复制代码

辽宁网友:虽然开机nginx会不启动,但是手动restart下就好了,好奇怪

  1. root@quiet-walk-1:~# lnmp restart
  2. +——————————————-+
  3. |    Manager for LNMP, Written by Licess    |
  4. +——————————————-+
  5. |              https://lnmp.org             |
  6. +——————————————-+
  7. Stoping LNMP…
  8. Stoping nginx… nginx is not running.
  9. [ ok ] Stopping mysql (via systemctl): mysql.service.
  10. Gracefully shutting down php-fpm  done
  11. Starting LNMP…
  12. Starting nginx…  done
  13. [ ok ] Starting mysql (via systemctl): mysql.service.
  14. Starting php-fpm  done

复制代码

甘肃网友:求助dalao

实在不行就换成centos7了,主要重装一次好麻烦
澳门网友:内存不够了吧,看看是不是吃到swap了。。。  
台湾网友:重启后内存free还有300多啊

swap倒是用了十几M

山东网友:额,换成成CENTOS7,没有这个问题了

环境还是my5.5 php7.2 nginx,之前还寻思用大便9省点资源,看来反而耽误了

以上信息转载自Hostloc。

未经允许不得转载:美国VPS_搬瓦工CN2 GIA VPS » 这个反代配置那里有问题吗,为什么会导致nginx不能开机自启

赞 (0) 打赏

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏