当前位置:网站首页>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/

这就表示配置成功了
边栏推荐
- JS解混淆-AST还原案例
- 蔚来杯2022牛客暑期多校训练营7 CFGJ
- 4D Summary: 38 Knowledge Points of Distributed Systems
- 几种绘制时间线图的方法
- SQLi-LABS Page-2 (Adv Injections)
- Flutter 绘制美不胜收的光影流动效果
- 发送激活邮件「建议收藏」
- CVPR22 Oral | shunt through multi-scale token polymerization from attention, code is open source
- mysql multi-table left link query
- 【微服务~Nacos】Nacos之配置中心
猜你喜欢

JSON 基本使用
![This article lets you quickly understand implicit type conversion [integral promotion]!](/img/16/4edc7ef23384b22d50ebd894b8911a.png)
This article lets you quickly understand implicit type conversion [integral promotion]!

4D Summary: 38 Knowledge Points of Distributed Systems

Space not freed after TRUNCATE table

Under the NVM node installation;The node environment variable configuration

How to Make Your Company Content GDPR Compliant

Flask introductory learning tutorial

第十七期八股文巴拉巴拉说(数据库篇)

POWER SOURCE ETA ETA Power Repair FHG24SX-U Overview

【微服务~Nacos】Nacos之配置中心
随机推荐
五星控股汪建国:以“植物精神”深耕赛道,用“动物精神”推动成长
unit test
宝塔实测-搭建LightPicture开源图床系统
One Pass 2074: [21CSPJ Popularization Group] Candy
Flask's routing (app.route) detailed
leetcode 刷题日记 计算右侧小于当前元素的个数
The kvm virtual machine cannot be started, NOT available, and the PV is larger than the partition
Basic JSON usage
国内手机厂商曾为它大打出手,如今它却最先垮台……
MLOps的演进历程
README_Albumentations
POWER SOURCE ETA ETA Power Repair FHG24SX-U Overview
Several ways to draw timeline diagrams
Bean life cycle
2022 首期线下 Workshop!面向应用开发者们的数据应用体验日来了 | TiDB Workshop Day
SecureCRT sets the timeout period for automatic disconnection
2.1.5 大纲显示问题
【测试】语句覆盖,判定覆盖,条件覆盖,路径覆盖
发送激活邮件「建议收藏」
Install win virtual machine on VMware