一、
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