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

红太狼 2020-11-08 06:58 699阅读 0赞

查看nginx的配置文件

路径:/etc/nginx

70

创建一个nginx的配置文件

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

70 2

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

70 3 修改nginx的根目录

70 4

浏览器请求结果:

70 5

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

70 6

代码复制:

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

  1. #charset koi8-r;
  2. #access_log /var/log/nginx/host.access.log main;
  3. root /data/www;
  4. index index.html index.htm;
  5. location / {
  6. #root /usr/share/nginx/html;
  7. #index index.html index.htm;
  8. # rewirte ^(.*).htmp /index.html;
  9. # root /data/www;
  10. # index index.html index.htm;
  11. #反向代理的头部信息
  12. proxy_set_header Host www.54php.cn;
  13. #反向代理
  14. proxy_pass http://wudi;
  15. }

负载均衡:

70 7

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

70 8

调试nginx

70 9

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

发表评论

表情:
评论列表 (有 0 条评论,699人围观)

还没有评论,来说两句吧...

相关阅读