1.安装nginx,可以查看官网上面的教程,很简单。我使用的版本是centos 7.0
2.配置文件 如下
cd /etc/nginx/ //进入配置文件目录
cp nginx.conf nginx.conf.bak //备份配置文件
vi nginx.conf //编辑配置文件
#添加一下的代码
#流媒体服务器
server {
listen 80;
server_name stream.sc.edu.cn;
location / {
root html;
index index.html index.htm;
proxy_pass http://192.168.100.28:8080;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
配置完成后,测试一哈nginx的配置文件有没有格式问题
nginx -t //检查格式问题
nginx -s reload //重新加载配置文件
最后测试发现还是不能正常代理转发端口。需要执行下面的命令
/usr/sbin/setsebool httpd_can_network_connect=1 //这条命令是关键
执行完毕后,测试可以访问网站了。
综上,测试完毕后,可以正常访问代理的网站了。



