亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

k8s部署nginx訪問Tomcat的實現(xiàn)示例

 更新時間:2023年08月08日 08:38:59   作者:大蝦別跑  
本文介紹了如何使用Kubernetes部署Nginx,并通過Nginx訪問Tomcat,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

1.nginx打包鏡像

#1、編寫DockerFile
mkdir /opt/my_nginx_dockerfile
cd /opt/my_nginx_dockerfile
cat >default.conf<<'EOF'?
server {
? ? listen ? ? ? 80;
? ? listen ?[::]:80;
? ? server_name ?localhost;
? ? #access_log ?/var/log/nginx/host.access.log ?main;
? ? location / {
? ? ? ? root ? /usr/share/nginx/html;
? ? ? ? index ?index.html index.htm;
? ? }
? ? location /tomcat/ {
? ? ? ? proxy_pass http://tomcat-web-service;
? ? ? ? proxy_set_header ? Host ? ?$host;
? ? ? ? proxy_set_header ? X-Forwarded-For $proxy_add_x_forwarded_for;
? ? ? ? proxy_set_header X-Real-IP $remote_addr;
? ? }
? ? #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;
? ? #}
}
EOF
cat ?>/opt/my_nginx_dockerfile/Dockerfile << 'EOF'
FROM nginx
WORKDIR /etc/nginx/conf.d
RUN echo "nginx v1 version" >/usr/share/nginx/html/index.html
ADD default.conf /etc/nginx/conf.d
EOF
cd /opt/my_nginx_dockerfile
#2、編譯鏡像
docker build -t 192.168.1:30012/k8s/my_nginx:v1 .
#3、登陸鏡像
docker login -u admin -p Harbor12345 192.168.1:30012
#4、推送至倉庫
docker push 192.168.1:30012/k8s/my_nginx:v1

2.Tomcat打包鏡像

#編寫DockerFile
mkdir -p /opt/my_tomcat_dockerfile
cat ?>/opt/my_tomcat_dockerfile/Dockerfile << 'EOF'
FROM tomcat:latest
RUN mkdir webapps/ROOT/tomcat -p && echo "My Tomcat v1 version">webapps/ROOT/tomcat/index.html
EOF
cd /opt/my_tomcat_dockerfile
#編譯鏡像
docker build -t 192.168.1:30012/k8s/my_tomcat:v1 .
#登陸鏡像
docker login -u admin -p Harbor12345 192.168.1:30012
#推送至倉庫
docker push 192.168.1:30012/k8s/my_tomcat:v1

3.部署nginx

cat >nginx-proxy.yml<<'EOF'
---
apiVersion: apps/v1
kind: Deployment
metadata:
? name: nginx-deployment
? labels:
? ? app: nginx
spec:
? replicas: 1
? selector:
? ? matchLabels:
? ? ? app: nginx
? template:
? ? metadata:
? ? ? labels:
? ? ? ? app: nginx
? ? spec:
? ? ? containers:
? ? ? - name: nginx
? ? ? ? image: 192.168.1:30012/k8s/my_nginx:v1
? ? ? ? ports:
? ? ? ? - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
? name: nginx-web-service
? labels:
? ? app: nginx-web-service
spec:
? type: NodePort
? selector:
? ? app: nginx
? ports:
? - protocol: TCP
? ? name: http
? ? port: 80
? ? targetPort: 80
? ? nodePort: 30086
EOF
kubectl apply -f nginx-proxy.yml

4.部署Tomcat

cat >tomcat-proxy.yml<<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
?name: tomcat-deployment
?labels:
? ?app: tomcat
spec:
?replicas: 1
?selector:
? ?matchLabels:
? ? ?app: tomcat
?template:
? ?metadata:
? ? ?labels:
? ? ? ?app: tomcat
? ?spec:
? ? ?containers:
? ? ?- name: tomcat
? ? ? ?image: 192.168.1:30012/k8s/my_tomcat:v1
? ? ? ?ports:
? ? ? ?- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
?name: tomcat-web-service
?labels:
? ?app: tomcat-web-service
spec:
?type: NodePort
?selector:
? ?app: tomcat
?ports:
? ?- protocol: TCP
? ? ?name: http
? ? ?port: 80
? ? ?targetPort: 8080
? ? ?nodePort: 30087
EOF
kubectl apply -f tomcat-proxy.yml

測試

curl http://192.168.1:30086/tomcat/

到此這篇關于k8s部署nginx訪問Tomcat的實現(xiàn)示例的文章就介紹到這了,更多相關k8s部署nginx訪問Tomcat內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Nginx中報錯:Permission denied與Connection refused的解決

    Nginx中報錯:Permission denied與Connection refused的解決

    這篇文章主要給大家介紹了在Nginx中報錯:13: Permission denied與111: Connection refused的解決方法,文中介紹的非常詳細,相信對大家具有一定的參考價值,需要的朋友們下面來一起看看吧。
    2017-04-04
  • nginx如何配置參數(shù)以及變量

    nginx如何配置參數(shù)以及變量

    這篇文章主要介紹了nginx如何配置參數(shù)以及變量問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • CentOS 7下安裝Nginx服務器

    CentOS 7下安裝Nginx服務器

    這篇文章主要為大家詳細介紹了CentOS 7下安裝Nginx服務器的相關資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • Nginx使用mirror指令實現(xiàn)接口復制

    Nginx使用mirror指令實現(xiàn)接口復制

    Nginx中使用mirro指令可以方便地實現(xiàn)接口請求的復制,這個功能非常適合用于流量監(jiān)控、數(shù)據(jù)收集或負載均衡,下面我們就來看看具體的用法吧
    2024-10-10
  • nginx反向代理用做內(nèi)網(wǎng)域名轉發(fā)

    nginx反向代理用做內(nèi)網(wǎng)域名轉發(fā)

    這篇文章主要為大家詳細介紹了nginx反向代理用做內(nèi)網(wǎng)域名轉發(fā),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Nginx+uwsgi+ssl配置https的詳細步驟

    Nginx+uwsgi+ssl配置https的詳細步驟

    nginx是一個輕量級的web服務器,在處理靜態(tài)資源和高并發(fā)有優(yōu)勢,uwsgi是一個基于python的高效率的協(xié)議,處理后端和動態(tài)網(wǎng)頁有優(yōu)勢,我這里使用的是Ubuntu18.04版本,服務器在阿里云,感興趣的朋友跟隨小編一起看看吧
    2023-10-10
  • Nginx中配置防盜鏈的方法實現(xiàn)

    Nginx中配置防盜鏈的方法實現(xiàn)

    在數(shù)字化時代,保護網(wǎng)站內(nèi)容免受盜鏈至關重要,Nginx防盜鏈通過檢查請求頭Referer字段來拒絕非法來源請求,本文就來詳細的介紹一下,感興趣的可以了解一下
    2024-10-10
  • nginx配置完rewrite瀏覽器提示將您重定向的次數(shù)過多的解決方法

    nginx配置完rewrite瀏覽器提示將您重定向的次數(shù)過多的解決方法

    本文主要介紹了nginx配置完rewrite瀏覽器提示將您重定向的次數(shù)過多的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-07-07
  • Nginx支持websocket的配置詳解

    Nginx支持websocket的配置詳解

    本文主要介紹了Nginx支持websocket的配置,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-03-03
  • Nginx SSI指令配置詳解

    Nginx SSI指令配置詳解

    這篇文章主要介紹了Nginx SSI指令配置詳解,本文講解了什么是SSI、為什么要用SSI、nginx配置SSI、頁面上配置、配置示例等內(nèi)容,需要的朋友可以參考下
    2015-04-04

最新評論