一般都是用阿里云了,Nginx负责外网,然后多台Apache是内网的,这样就是省带宽。
额~搞一下。貌似别人说宽带最贵。内网的就是之间就是带宽免费。
阿里系的产品蛮不错的。以后多研究写一些文章。
现在在虚拟机搞。下一次,搞3台阿里云机试试。
有域名就外网Nginx设置一个域名,内网的不需要。
首先nginx用80端口。httpd用8800端口。
里面写个php页面

去改nginx的配置文件。
cd /usr/local/nginx/conf/
vim nginx.conf
把root /web/ngin 隐藏。加#号。写下面这句话,有域名用域名
proxy_pass http://localhost:8800;

//重启nginx
/usr/local/nginx/sbin/nginx -s reload //重启
会看见,访问80和8800都一样了。执行了,反向代理。

之后在httpd的php页面都加上
echo "<pre>";
print_r($_SERVER);
echo "</pre>";

HTTP_HOST 主机地址
REMOTE_ADDR 客户端ip
上面两个在nginx80端口里面都是错了。
跑去设置nginx的配置,加上两行内置变量,还有更多请百度
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;

重启nginx来看看。

设置之后主机ip和客户端ip都拿到了。
好了之后,来搞一个自己写一个上去
proxy_set_header myname hehe;

重启nginx会看见下面这张图。

网友评论