zoukankan      html  css  js  c++  java
  • nginx简单配置

    通过
    http://192.168.0.100:10003/AimDir
    访问
    http://192.168.0.100:10006/training-match/AimDir

    找到nginx的配置文件,例如/etc/nginx/nginx.conf

    # 先添加upstream 用于负载均衡
    upstream upstreamName {
        # upstreamName服务IP和端口
        server 192.168.0.100:10006;
    }

    然后在http模块内添加server模块

    server {
        listen 10003;
        server_name 192.168.0.100;

        location /AimDir {
            proxy_pass http://192.168.0.100:10006/redundantDir/AimDir;
        }
    }

    或者直接把/后面的内容去掉也行
    server {
        listen 10003;
        server_name localhost;

        location / {
            proxy_pass http://upstreamName/redundantDir/;
        }
    }

    解析:
    这个模块的意思是:

    将http://{server_name}:{listen}{location}转发为proxy_pass
    即http://192.168.0.100:10003/xxx
    转发为http://192.168.0.100:10006/training-match/xxx;

    例如:在浏览器发送http://192.168.0.100:10003/test.html后,经nginx转发为http://192.168.0.100:10006/redundantDir/test.html去对应的服务器取数据,然后再返回给发送http://192.168.0.100:10003/test.html请求的人。

  • 相关阅读:
    IMYSQL-叶金荣
    mysql命令
    实效云计算用户组(ECUG) 与 阿里云
    GO 语言
    MYSQL 源代码编绎脚本
    MYSQL 源代码学习
    LINUX 性能工具使用
    CentOS 5.8 上安装 systemtap-2.6 转
    mysql php nginx
    redis 安装
  • 原文地址:https://www.cnblogs.com/czp2016/p/15336626.html
Copyright © 2011-2022 走看看