NGINX配置文件(自用持续更新)

一、

1.如果代理的应用过多,可以单独配置一个主文件这样方便管理

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    include /data/nginx_config/*.conf;
}

#include /data/nginx_config/*.conf;为每个应用的单独nginx配置文件路径,文件内只写server就行

2.单独配置文件内容:

server {
     listen       11111;
     server_name  gwst_mange;

        location / {
        if (!-e $request_filename) {
                rewrite ^(.*)$ /index.html?s=$1 last;
                break;
                        }

                root   /data/text//web;
                index  index.html;
        }

        location ^~/di-manage/ {
            proxy_pass http://localhost:9995/di-manage/;
        }


        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded $proxy_add_x_forwarded_for;                
}

二、隐藏ngin版本设置

要隐藏nginx版本信息,你需要编辑nginx的配置文件,通常位于 /etc/nginx/nginx.conf 或者 /usr/local/nginx/nginx.conf。在 http 块中添加 server_tokens off; 语句即可。这个设置会关闭nginx的版本信息显示,nginx配置文件以实际路径为准

三、nginx非root用户启动

首先有一个非root用户,没有需要创建一个用户

然后修改nginx.conf配置文件将user root修改为user  创建的用户

然后切换到创建的用户,重启nginx服务

四、-bash: nginx: 未找到命令 (command not found) 解决方案

1.查看是否安装成功

ps -ef | grep nginx

出现此图表示安装成功,否则需要安装nginx

2.修改环境变量

vim /etc/profile
3.生效配置

source /etc/profile
4.重启nginx

nginx -s reload
 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值