Nginx的使用说明

配置

  • 
            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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值