k8s集群中部署微服务项目前端代理服务 Nginx

2023-11-13

k8s集群中部署微服务项目前端代理服务 Nginx

一、微服务项目静态资源准备

在这里插入图片描述

# mkdir sangomall-proxy
# cd sangomall-proxy/
[root@k8s-master01 sangomall-proxy]# ls
conf  Dockerfile  html  html.tar.gz
[root@k8s-master01 sangomall-proxy]# cd conf/
[root@k8s-master01 conf]# docker run -d nginx:latest
[root@k8s-master01 conf]# docker ps
[root@k8s-master01 conf]# docker cp id:/etc/nginx/default.conf .
[root@k8s-master01 conf]# ls
default.conf
[root@k8s-master01 conf]# docker stop id;docker rm id;
[root@k8s-master01 conf]# vim default.conf
[root@k8s-master01 conf]# cat default.conf

upstream sangomall {//反向代理
      server mall-gateway.sangomall.svc.cluster.local.:8072;
    }

server {
    listen       80;
    server_name  *.msb.com;

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


    location /static/ {
       root   /usr/share/nginx/html;
    }


    location / {
       proxy_set_header Host $host;
       proxy_pass http://sangomall;
    }


    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
[root@k8s-master01 sangomall-proxy]# ls
conf  Dockerfile  html  html.tar.gz
[root@k8s-master01 sangomall-proxy]# cd html
[root@k8s-master01 html]# ls
es  index.html  static
[root@k8s-master01 html]# cat es/fenci.txt
sango
mall
[root@k8s-master01 html]# cat index.html
<h1>sangomall </h1>
[root@k8s-master01 html]# ls static
cart  index  item  login  order  reg  search
[root@k8s-master01 sangomall-proxy]# cd html/
# tar czvf html.tar.gz *
[root@k8s-master01 sangomall-proxy]# mv html.tar.gz ../
[root@k8s-master01 sangomall-proxy]# vim Dockerfile
[root@k8s-master01 sangomall-proxy]# cat Dockerfile
FROM nginx

MAINTAINER nextgo@126.com

RUN rm -rf /etc/nginx/conf.d/*

COPY conf/* /etc/nginx/conf.d/


ADD html.tar.gz  /usr/share/nginx/html/

EXPOSE 80

ENTRYPOINT nginx -g "daemon off;"

二、微服务项目前端代理服务镜像制作

[root@k8s-master01 sangomall-proxy]# docker build -t docker.io/nextgomsb/nginx:v1 .
[root@k8s-master01 sangomall-proxy]# docker images
REPOSITORY                                TAG       IMAGE ID       CREATED         SIZE
nextgomsb/nginx                           v1        f83f673f91df   4 seconds ago   173MB
[root@k8s-master01 sangomall-proxy]# docker run -it docker.io/nextgomsb/nginx:v1 /bin/bash

在这里插入图片描述
在这里插入图片描述

[root@k8s-master01 sangomall-proxy]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: nextgomsb
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@k8s-master01 sangomall-proxy]# docker push docker.io/nextgomsb/nginx:v1

在这里插入图片描述

三、微服务项目前端代理服务部署及访问

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

四、添加微服务访问路由规则

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

五、添加域名解析

[root@dnsserver ~]# cat /var/named/msb.com.zone
$TTL 1D
@       IN SOA  msb.com admin.msb.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       NS      ns.msb.com.
ns      A       192.168.10.145
harbor  A       192.168.10.146
reg-test        A       192.168.10.70
kibana          A       192.168.10.70
rabbitmq        A       192.168.10.70
nacos-server    A       192.168.10.70
zipkin-server   A       192.168.10.70
sentinel-server A       192.168.10.70
skywalking-ui   A       192.168.10.70
rocketmq-dashboard      A       192.168.10.70
mall-gateway    A       192.168.10.73

mall    A       192.168.10.70
item    A       192.168.10.70
seckill A       192.168.10.70
search  A       192.168.10.70
auth    A       192.168.10.70
cart    A       192.168.10.70
order   A       192.168.10.70
[root@dnsserver ~]# systemctl restart named

六、微服务商城访问

在这里插入图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

k8s集群中部署微服务项目前端代理服务 Nginx 的相关文章

随机推荐

  • 近源渗透学习

    一 近源渗透 近源渗透测试是网络空间安全领域逐渐兴起的一种新的安全评估手段 它是一种集常规网络攻防 物理接近 社会工程学及无线电通信攻防等能力于一体的高规格网络安全评估行动 网络安全评估小组在签订渗透测试授权协议后 通过乔装 社工等方式实地
  • git 常用命令---修改Git默认编辑器为vim

    1 配置 git config global user email you example com 配置git用户名 git config global user name Your Name 配置git邮件 git config glob
  • C++类使用未定义类型 use undefined class

    a h file include
  • [论文笔记]AutoAssign 阅读笔记

    AutoAssign 阅读笔记 AutoAssign Differentiable Label Assignment for Dense Object Detection 摘要 1 引言 2 相关工作 固定标签分配 Fixed Label
  • Vue.js 生命周期函数

    系列文章目录 Vue js基础简答题 文章目录 系列文章目录 前言 一 创建阶段 1 beforeCreate 2 created 3 beforeMount 4 mounted 二 运行阶段 1 beforeUpdate 2 update
  • 字符设备驱动详解(主次设备号、注册/卸载字符设备驱动、创建设备节点、地址映射)

    1 主次设备号 1 主次设备号是内核用来索引设备的 每个主次设备号在内核中都是唯一的 每个注册的设备都有一个分配的主次设备号 2 同一个主设备号可以有多个从设备号 主设备是对应的驱动程序 次设备号对应设备文件所指的设备 一个Soc可能接同样
  • Odoo进销存(采购、销售、仓库)入门教程 - 上

    运行环境 Ubuntu14 04 Odoo8 0 作者 苏州 微尘 0 前言 Odoo OpenERP 作为一款优秀的开源ERP软件 开发历史已有10年之久 随着系统的发展成熟 已有越来越多的公司借助Odoo管理日常业务的方方面面 本文以一
  • undo表空间故障特殊恢复(一)

    author skate time 2010 09 09 undo表空间故障特殊恢复 一 这个测试的是instance recover 单实例里就是crash recovery 的恢复不需要故障undo里的数据 一般的情况instance
  • python修改字典内key对应的值的代码

    下面代码段是关于python修改字典内key对应的值的代码 希望对码农有用 d2 spam 2 ham 1 eggs 3 make a dictionary print d2 order is scrambled d2 ham grill
  • python爬虫网页编码问题——网页gbk编码

    爬虫的时候遇到一个网页的编码是有问题 添加了这句 没问题了 20210124 21 34 response encoding gbk
  • 基于Linux开发python项目

    在某些公司要求中 我们不会直接在Windows系统上做项目的开发 有时候会采用在linux系统上开发 而这分为两种情况 1 直接在本地搭建虚拟机 虚拟机上面装centos镜像 项目运行在本地虚拟机上 大部分原因都是项目的某些依赖包在Wind
  • 4 业务分析师

    在每个软件项目中 都有人在显式或隐式地扮演业务分析师 BA 的角色 业务分析师是能够在组织中促进变化的人 他们通过定义需求和向干系人推荐有价值的解决方案来促进这些变化 分析师获取和分析他人的观点 将收集到的信息转换为需求规范说明 并于其他干
  • 如何从无序链表中移除重复项--Java版

    题目描述 给定一个没有排序的链表 去掉其重复项 并保留原顺序 如链表1 gt 3 gt 1 gt 5 gt 5 gt 7 去掉重复项变为1 gt 3 gt 5 gt 7 方法一 顺序删除 思路 通过双重循环直接在链表上执行删除操作 外层循环
  • 对习乐app的某课程的所有题目爬取

    这学期就想把习乐题库刷空 一直没时间弄 期末来了 课少了 搞起来 习乐好像是一个一个学长写的app 但是对不住了 增加了点垃圾数据 23333 思路 1 手机或模拟器抓包 分析提交自测数据包 查看试卷数据包 2 模拟上面的数据包 3 清洗数
  • Linux下ntpdate时间同步

    原文地址 http gaoxingf blog 51cto com 612518 121959 作者 高兴F Linux下ntpdate时间同步 Ntp服务器安装配置 RedHat服务器可以下载rpm安装包 然后执行 rpm ivh ntp
  • Linux安装MySQL

    Linux安装MySQL 链接 MySQL官网9 7 18的下载 查看是否已经安装了mariadb 检查linux是否安装了mariadb数据库 mariadb数据库是mysql的分支 是免费开源的 mariadb和msyql会有冲突 首先
  • vue中用echart写饼状图

    用echart饼状图实现男女比例 效果图如下 实现代码如下
  • 静态代码扫描工具汇总

    一 概述 在软件开发过程中 开发团队往往要花费大量的时间和精力发现并修改代码缺陷 传统的代码评审 同事复审 通过人工方式来检查缺陷仍然是一件耗时耗力的事情 而静态代码扫描工具能够在代码构建过程中帮助开发人员快速 有效的定位代码缺陷并及时纠正
  • Qt 设置窗口背景图片的几种方法

    1 在paintEvent事件中绘制图片 void Widget paintEvent QPaintEvent ev QPainter painter this painter drawPixmap rect QPixmap bg jpg
  • k8s集群中部署微服务项目前端代理服务 Nginx

    k8s集群中部署微服务项目前端代理服务 Nginx 一 微服务项目静态资源准备 mkdir sangomall proxy cd sangomall proxy root k8s master01 sangomall proxy ls co