配置
-
location /request/ { root /; proxy_set_header Host $host; #请求主机头字段,否则为服务器名称。 proxy_headers_hash_max_size 1024; #存放http报文头的哈希表容量上限,默认为512个字符 proxy_headers_hash_bucket_size 128; #设置头部哈希表大小 默认为64 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; proxy_set_header Accept-Encoding ""; proxy_pass http://localhost:8888/login/; #请求替换地址 例如要请求http://localhost:8888/login/ 也就是请求http://localhost/request/ } l
systemctl启动配置
需要将nginx.conf的配置文件进行开启pid的存储
将#pid logs/nginx.pid; 去掉#的注释
然后进行编辑nginx.service
vi /lib/systemd/system/nginx.service
##配置参数解释##
[Unit]
Description=nginx
##描述
After=network.target
##描述服务类别,网络服务模式
[Service]
Type=forking
##后台运行形式
PIDFile=/usr/local/nginx/logs/nginx.pid
##PID文件位置 ,记录进程号
ExecStart=/usr/local/nginx/sbin/nginx
##启动服务脚本
ExecReload=/usr/bin/kill -s HUP $MAINPID
##根据PID(nginx进程号)重载配置
ExecStop=/usr/bin/kill -s QUIT $MAINPID
##根据PID(nginx进程号)终止进程
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重载systemctl
systemctl daemon-reload
之后使用命令:
启动服务 systemctl start nginx
停止服务 systemctl stop nginx
重启服务 systemctl restart nginx
1590

被折叠的 条评论
为什么被折叠?



