Dockerfile打包nginx鏡像的實(shí)現(xiàn)步驟
Dockerfile:
FROM nginx ENV WORK_DIR /project ENV GATEWAY_IP=127.0.0.1 USER root RUN mkdir ${WORK_DIR} #拷貝前端項(xiàng)目 ADD chinaunicom-digitward-portal-web-view.tar.gz ${WORK_DIR} ADD mdt-view.tar.gz ${WORK_DIR} ADD unicom-cloud-medical-admin-view.tar.gz ${WORK_DIR} #拷貝nginx配置文件 COPY nginx.conf /etc/nginx/nginx.conf COPY 80.conf /etc/nginx/conf.d/default.conf EXPOSE 80 #將 default.conf 內(nèi)的${GATEWAY_IP}替換為環(huán)境變量的值(K8s部署的時(shí)候后端的ip地址時(shí)不固定的,需要?jiǎng)討B(tài)讀取) CMD ["/bin/bash", "-c", "envsubst '${GATEWAY_IP}' < /etc/nginx/conf.d/default.conf > temp.conf; mv temp.conf /etc/nginx/conf.d/default.conf; nginx -g \"daemon off;\""]
default.conf配置
server { listen 80; # 統(tǒng)一規(guī)則的前端代理 location ~ /.*-view { root /project; index index.html index.htm; } # 統(tǒng)一規(guī)則的前端代理 location / { #訪(fǎng)問(wèn)根路徑時(shí)跳轉(zhuǎn)至 對(duì)應(yīng)的路徑 #$scheme讀取請(qǐng)求的類(lèi)型如:http,https #$http_host 讀取請(qǐng)求域名和端口 return 301 $scheme://$http_host/web-view/#/login?UMSLogin=true&appUMSId=mdt; } #病房網(wǎng)關(guān) Websocker location /digit_ward_gateway/.*/ws { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 3600; proxy_pass http://${GATEWAY_IP}:7777/; } # 數(shù)字化病房網(wǎng)關(guān)服務(wù) location /digit_ward_gateway/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $proxy_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://${GATEWAY_IP}:7777/; } # location /browser/ { #proxy_set_header X-Forwarded-Proto $scheme; #proxy_set_header Host $http_host; #proxy_set_header X-Real-IP $remote_addr; #proxy_pass ${SW_COLLECTOR}; #} }
nginx.conf
user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; charset utf-8; server_tokens off; #允許websocket map $http_upgrade $connection_upgrade { default keep-alive; 'websocket' upgrade; } log_format access_json '{ "@timestamp":"$time_iso8601",' '"@version":"1",' '"client":"$remote_addr",' '"url":"$uri",' '"status":"$status",' '"domain":"$host",' '"host":"$server_addr",' '"size":"$body_bytes_sent",' '"responsentime":"$request_time",' '"referer":"$http_referer",' '"useragent":"$http_user_agent",' '"upstreampstatus":"$upstream_status",' '"upstreamaddr":"$upstream_addr",' '"upstreamresponsetime":"$upstream_response_time"' '}'; access_log /var/log/nginx/access.log access_json; keepalive_timeout 3600; send_timeout 300; sendfile on; client_max_body_size 10G; client_body_buffer_size 2m; fastcgi_connect_timeout 1800; fastcgi_send_timeout 1800; fastcgi_read_timeout 1800; fastcgi_buffer_size 64k; fastcgi_buffers 8 128k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; proxy_connect_timeout 3600; proxy_send_timeout 1800; proxy_read_timeout 1800; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 3; gzip_types text/plain application/json application/javascript application/x-javascript application/css application/xml application/xml+rss text/javascript application/x-httpd-php image/jpeg image/gif image/png image/x-ms-bmp application/wasm; gzip_vary off; include /etc/nginx/conf.d/*.conf; }
到此這篇關(guān)于Dockerfile打包nginx鏡像的實(shí)現(xiàn)步驟的文章就介紹到這了,更多相關(guān)Dockerfile打包nginx鏡像內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
利用Nginx實(shí)現(xiàn)反向代理Node.js的方法詳解
這篇文章主要給大家介紹了關(guān)于利用Nginx實(shí)現(xiàn)反向代理Node.js的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-08-08Nginx index指令使用及設(shè)置網(wǎng)站默認(rèn)首頁(yè)
index指令用于指定處理請(qǐng)求時(shí)使用的默認(rèn)文件,本文主要介紹了Nginx index指令使用及設(shè)置網(wǎng)站默認(rèn)首頁(yè),具有一定的參考價(jià)值,感興趣的可以了解一下2024-07-07Crontab+Shell做Nginx日志切割腳本實(shí)例代碼
本篇文章主要介紹了Crontab+Shell做Nginx日志切割腳本實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-05-05使用Nginx部署Vue項(xiàng)目全過(guò)程及踩坑記錄
這篇文章主要介紹了使用Nginx部署Vue項(xiàng)目全過(guò)程及踩坑記錄,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02Nginx域名轉(zhuǎn)發(fā)https訪(fǎng)問(wèn)的實(shí)現(xiàn)
這篇文章主要介紹了Nginx域名轉(zhuǎn)發(fā)https訪(fǎng)問(wèn)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10Windows系統(tǒng)下安裝及部署Nginx詳細(xì)教程(含多個(gè)站點(diǎn)部署)
Nginx是一個(gè)很強(qiáng)大的高性能Web和反向代理服務(wù),也是一種輕量級(jí)的Web服務(wù)器,可以作為獨(dú)立的服務(wù)器部署網(wǎng)站,應(yīng)用非常廣泛,這篇文章主要給大家介紹了關(guān)于Windows系統(tǒng)下安裝及部署Nginx(含多個(gè)站點(diǎn)部署)的相關(guān)資料,需要的朋友可以參考下2024-01-01