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

这就表示配置成功了
边栏推荐
- TF generates uniformly distributed tensor
- ACM MM 2022 | Cloud2Sketch: 长空云作画,AI笔生花
- 宝塔实测-搭建LightPicture开源图床系统
- LeetCode26:删除有序数组中的重复项
- Xiaohei's leetcode journey: 94. Inorder traversal of binary trees (supplementary Morris inorder traversal)
- Under the NVM node installation;The node environment variable configuration
- 一文让你快速了解隐式类型转换【整型提升】!
- STC8H开发(十五): GPIO驱动Ci24R1无线模块
- Blender程序化建模简明教程【PCG】
- 2022年中国第三方证券APP创新专题分析
猜你喜欢

好未来,想成为第二个新东方
![[Implementation of the interface for adding, deleting, checking, and modifying a double-linked list]](/img/49/ebedcd4d27aa608360ac17e504f36d.png)
[Implementation of the interface for adding, deleting, checking, and modifying a double-linked list]

AI+Medical: Using Neural Networks for Medical Image Recognition and Analysis

一文让你快速了解隐式类型转换【整型提升】!

TRUNCATE表之后空间未释放

leetcode 38. 外观数列

简单问题窥见数学

MLOps的演进历程

2022年中国第三方证券APP创新专题分析

FileZilla搭建FTP服务器图解教程
随机推荐
[Cloud Native] 4.2 DevOps Lectures
Basic JSON usage
json case
2.1.5 大纲显示问题
SecureCRT background color
腾讯继续挥舞降本增效“大刀”,外包员工免费餐饮福利被砍了
Interviewer: How to deal with Redis big key?
Deceptive Dice
AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
Rust 解引用
大型分布式存储方案MinIO介绍,看完你就懂了!
埃氏筛选法:统计素数个数
AI识万物:从0搭建和部署手语识别系统
接口自动化测试实践指导(上):接口自动化需要做哪些准备工作
Rust dereference
宝塔实测-搭建LightPicture开源图床系统
README_Albumentations
小程序+自定义插件的关键性
In-depth analysis of Apache EventMesh cloud-native distributed event-driven architecture
聊聊SQL语句中 DDL 、DML 、DQL 、DCL 分别是什么