nginx 自救指南

1、nginx配置的路径常放置在

/etc/nginx

2、查看nginx进程,kill主进程才行

 ps aux | grep nginx

3、启动

systemctl start nginx.service

4、重启

systemctl restart nginx.service

5、停止

systemctl stop nginx.service

一份可用的nginx配置:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
# pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    error_log  /var/log/nginx/access.log;  

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       9000;
        listen  [::]:9000;
        server_name  gateway_http;
        server_tokens off;

        access_log  /var/log/nginx/access.log  main;
				
				# 文件存放的路径应该为'/app/web/game'
        location ~ /game {
            index index.html;
            root /app/web;
        }
        
        # 文件存放的路径应该为'/app/web/h5'
        location ~ / {
            index index.html;
            root /app/web/h5;
        }
        
        # / 的配置应该放在最后,否则'/game'的访问真是路径会变为‘/app/web/h5/game’
    }
}

6、https重定向为http

有必要说下这个故事,有个h5扫码的功能需要在localhost或https环境下才能启动摄像头,但上线后发现https被重定向为http,最后发现是访问地址的问题
https://xxx.com/ 会在nginx被重定向为http://xxx.com
直接访问 https://xxx.com

7、尝试自己配置https证书,网上大部分方法不行或者有些步骤不完整,个人经验是生成的证书不对

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值