噢噢 nigix

2023-12-29 13:58
文章标签 nigix

本文主要是介绍噢噢 nigix,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. 基础配置

worker_processes  1;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       80;server_name  project.hellowood.com;access_log  logs/project.access.log;location / {proxy_pass http://127.0.0.1:8080;proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

访问project.hellowood.com 实际会访问该 IP 下的8080端口

2. 不同的 URL 访问不同的服务器

  • 配置 Server 节点
    server {listen       80;server_name  project.hellowood.com;access_log  logs/project.access.log;location / {proxy_pass http://127.0.0.1:8080;proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}server {listen       80;server_name  introduce.hellowood.com;access_log  logs/introduce.access.log;location / {proxy_pass http://127.0.0.1:8081;proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}server {listen       80;server_name  helloworld.com;access_log  logs/helloworld.access.log;location / {proxy_pass http://127.0.0.1:8082;proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

访问project.hellowood.com 实际会访问该 IP 下的8080端口 
访问introduce.hellowood.com 实际会访问该 IP 下的8081端口 
访问helloworld.com 实际会访问该 IP 下的8082端口


3. 不同的项目路径访问不同的服务器

    server {  listen       80;  server_name  hellowood.com;  location / {  root   html;  index  index.html index.htm;  }  location /helloworld {  proxy_pass http://192.168.101.101:8080/helloworld;  proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  }  location /hi {  proxy_pass http://192.168.101.101:8080/hi;  proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  }  location /howareyou {  proxy_pass http://192.168.101.101:8088/howareyou;  proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  }  location /introduce {  proxy_pass http://10.2.10.11:9999/introduce;  proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  }  location /lalala {  proxy_pass http://www.lalala.com;  proxy_set_header   Host    $host;  proxy_set_header   X-Real-IP   $remote_addr;   proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;  }error_page   500 502 503 504  /50x.html;  location = /50x.html {  root   html;  }  }  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44

访问hellowood.com 实际会访问该 IP 下的 Nginx 目录下的静态页面 
访问hellowood.com/helloworld 实际会访问http://192.168.101.101:8080/helloworld 
访问hellowood.com/hi 实际会访问http://192.168.101.101:8080/hi 
访问hellowood.com/howareyou 实际会访问http://192.168.101.101:8088/howareyou 
访问hellowood.com/introduce 实际会访问http://10.2.10.11:9999/introduce 
访问hellowood.com/lalala 实际会访问http://www.lalala.com

这篇关于噢噢 nigix的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/549642

相关文章

mac安装nigix

1. 查看是否存在 nginx 执行brew search nginx 命令查询要安装的软件是否存在 brew search nginx  2. 安装nginx brew install nginx  3. 查看版本 nginx -v 4. 查看信息 查看ngxin下载的位置以及nginx配置文件存放路径等信息  brew info nginx 下载的存放路径

nigix部署静态资源读取资源数据失败405

混合开发:产品原型做一个地级市三级联动,h5方面是json静态数据 问题:放在tomcat上面可以访问json数据 放在nigix失败 解决:ajax请求  post改成get 给了一个json请求,在HTTP接口测试工具中post请求结果返回405状态,get请求则返回数据。搜了一番发现返回405是因为Apache、IIS、Nginx等绝大多数web服务器,都不允许静态文件响应POS