当前位置:网站首页>17-GuliMall 搭建虚拟域名访问环境
17-GuliMall 搭建虚拟域名访问环境
2022-08-09 21:54:00 【鸣鼓ming】
1.原理
1.先在windows配置我们的域名转发到nginx
2.然后在nginx配置请求转发到gateway网关服务
3.gateway网关服务将请求转发到我们对应的服务
2.配置步骤
1.windows配置
修改 C:\Windows\System32\drivers\etc目录下的hosts文件
在文件末尾添加域名映射, ip是你的nginx的地址
192.168.56.103 gulimall.com
测试一下, 没有问题
2.nginx配置
1.先了解一下nginx.conf配置文件的知识
2.修改挂载目录下的nginx.conf文件
按照下图添加内容, 配置上游服务器, 也就是我们的gateway网关模块的地址
修改内容
upstream gulimall{
server 192.168.56.1:9000;
}
ip地址不唯一, 但是一定是要从虚拟机内部可以访问到windows的地址, 这个地址可以是电脑连接wifi后获得的ip地址, 这里我使用的是电脑分配给VirtualBox的ip地址.
命令行输入下面的命令可以查看ip
ipconfig
3.修改ngnix的配置子文件
将conf.d文件夹中的default.conf文件复制一份,命名为gulimall.conf
修改gulimall.conf的内容
修改内容
#监听域名gulimall.com的请求
server_name gulimall.com;
#将gulimall.com/请求转发到上游服务器,
#gulimall是上游服务器配置的名称
location / {
proxy_set_header Host $host;
proxy_pass http://gulimall;
}
注意
proxy_set_header Host $host;
因为设置请求代理后会丢失很多东西, 比如请求头host, cookie等,
这里我们先把请求头加上, 后面有需要我们再加上其它的东西
重启nginx容器
docker resatrt 容器id
3.gateway配置
在gateway网关服务模块的配置文件中添加路由信息
- id: gulimall_host_route
uri: lb://gulimall-product
predicates:
- Host=gulimall.com
3.测试
启动我们的网关服务模块, 商品服务模块
浏览器使用域名访问
http://gulimall.com/
这就表示配置成功了
边栏推荐
- mysql multi-table left link query
- Five Star Holdings Wang Jianguo: Deepen the track with "plant spirit" and promote growth with "animal spirit"
- Basic operations of openGauss database (super detailed)
- [Microservice~Nacos] Configuration Center of Nacos
- Ehrlich screening method: Counting the number of prime numbers
- abstract class or interface
- 台风生成,广州公交站场积极开展台风防御安全隐患排查
- 5个 Istio 访问外部服务流量控制最常用的例子,你知道几个?
- TF generates uniformly distributed tensor
- 每日一R「02」所有权与 Move 语义
猜你喜欢
随机推荐
每日一R「02」所有权与 Move 语义
STC8H Development (15): GPIO Drives Ci24R1 Wireless Module
Solution: Edu Codeforces 109 (div2)
Synchronization lock synchronized traces the source
万字总结:分布式系统的38个知识点
Common commands and technical function modules of Metasploit
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
聊天尬死名场面,你遇到过吗?教你一键获取斗图表情包,晋升聊天达人
In programming languages, the difference between remainder and modulo
埃氏筛选法:统计素数个数
深度剖析 Apache EventMesh 云原生分布式事件驱动架构
Chatting embarrassing scenes, have you encountered it?Teach you to get the Doutu emoticon package with one click, and become a chat expert
阿里云架构师金云龙:基于云XR平台的视觉计算应用部署
五星控股汪建国:以“植物精神”深耕赛道,用“动物精神”推动成长
第十七期八股文巴拉巴拉说(数据库篇)
abstract class or interface
Quotefancy ,提供鼓舞人心语录的壁纸网站 - 倾城之链
mysql multi-table left link query
TF generates uniformly distributed tensor
How do task flow executors work?