栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Nginx反向代理 网关路由转发

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Nginx反向代理 网关路由转发

nginx反向代理 域名gulimall.com 通过映射关系对应 虚拟机地址ip(192.168.198.129)。虚拟机中的nginx服务器会监听gulimall.com:80的请求,一旦有请求就会反向代理至网关的地址 http://192.168.106.91:88。 nginx主要配置:http块,upstream 网关名, server代码块
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;
    upstream gulimall{
        server 192.168.106.91:88;
    }

	server {
		listen       80;
		server_name  gulimall.com;   //监听gulimall.com:80

		location / {
		   proxy_set_header Host $host;  //反向代理过程中可能会丢失Host头
		   proxy_pass gulimall;     //此处与upstream  一直
		}
	}
}
网关路由转发 网关接受到域名为gulimall.com的请求,就会通过路由规则转发至注册中心的微服务gulimall-product中http://192.168.106.91:10000 网关配置
spring:
  cloud:
    gateway:
      routes:
	  ....
	
	  //来自nginx的域名,要放到最后面。
        - id: gulimall_host_rout
          uri: lb://gulimall-product  #lb代表负载均衡
          predicates:
            - Host=**.gulimall.com    #Host
从而实现了请求从nginx->网关->微服务。 即http://gulimall.com:(80)/ --> http://192.168.106.91:10000/
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/851510.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号