打开nginx.conf配置文件,把以下代码放到http{}里
server {
listen 8866;#端口
#代理本地静态文件
location / {#浏览器访问路径 ip:8866/
root /opt/softwares/;#文件服务器路径
index index1.html index.htm;#文件名如果找不到index1.html 就找index.htm
}
#代理其他网站页面
location /ccc.html {#浏览器访问路径 ip:8866/ccc.html
proxy_pass https://www.chinanews.com/gn/2023/03-09/9968330.shtml;
}
}
ip禁用,如果不让某个ip访问,我仅需要再location下加deny ip; 我们用自己本地IP来测试,加上之后重启nginx
server {
listen 8866;#端口
#IP禁用案例
location /ccc.html {#浏览器访问路径 ip:8866/ccc.html
deny 本地ip;
proxy_pass https://www.chinanews.com/gn/2023/03-09/9968330.shtml;
}
}
我们再次访问 ip:8866/ccc.html,就会提示403