liunx中服务搭建nginx解析《十二》

查看nginx的配置文件

路径:/etc/nginx

创建一个nginx的配置文件

 修改nginx.config进行查看调用的路径

在请求浏览器域名展示页面的地址:

 修改nginx的根目录

浏览器请求结果:

 

 nginx的反向代理和负载均衡=============================

代码复制:

[root@www conf.d]# cat wudi.conf 
upstream wudi{
         server 118.89.106.129:80;
}
server {
    listen       80;
    listen       99;
    server_name  localhost www.wudi654321.com 192.168.150.138;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    root  /data/www;
    index  index.html index.htm;
    location / {
        #root   /usr/share/nginx/html;
        #index  index.html index.htm;
       # rewirte ^(.*)\.htmp /index.html;
       # root  /data/www;
       # index  index.html index.htm;
      #反向代理的头部信息
     proxy_set_header Host www.54php.cn;
       #反向代理
      proxy_pass http://wudi;
    }
负载均衡:

 结果:同一个浏览器地址响应的结果不一样:

 调试nginx

 add_header Content-Type"text/plain;charset=utf-8";
   return 200 "$http_host";
调试时需要把反向代理关闭一下

猜你喜欢

转载自blog.csdn.net/wd521521/article/details/81487605
今日推荐