nginx反代配置httpswwwbaiducom
- 安装nginx
首先安装nginx,使用以下命令:
sudo apt-get update
sudo apt-get install nginx
- 配置反向代理
在nginx配置文件中添加以下内容:
server {
listen 80;
server_name example.com; # 修改为你的域名
location / {
proxy_pass https://www.baidu.com/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
其中,proxy_pass指定反向代理的目标网站,proxy_set_header设置请求头。
- 重启nginx
完成配置后,需要重启nginx以使配置生效:
sudo service nginx restart
现在访问http://example.com,将会被反向代理到https://www.baidu.com/。
原文地址: https://www.cveoy.top/t/topic/buoM 著作权归作者所有。请勿转载和采集!