-
环境:CentOS7
-
安装Nginx
yum install nginx
- 启动nginx服务
systemctl start nginx
- 设置开机自动启动
systemctl enable nginx
- 重启Nginx
systemctl restart nginx
- 重新加载Nginx,当你修改配置文件后可以使用此命令,使修改生效
nginx -s reload
或者:
systemctl reload nginx
- 正向代理模板
server{
listen 80; #这里填监听端口
server_name #这里填域名 (如www.baidu.com) 如果暂时没有域名就填阿里云的公网ip
location /{
proxy_pass (这里填完整的网页地址,如https://www.bilibili.com/);
}
}
- 如果地址前缀(https://)不写全会报错!