first
This commit is contained in:
28
docker/nginx/Dockerfile
Normal file
28
docker/nginx/Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
||||
FROM ubuntu:24.04 AS builder
|
||||
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y nodejs npm && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY ./web /build
|
||||
WORKDIR /build
|
||||
|
||||
RUN npm --registry=https://registry.npmmirror.com install
|
||||
RUN npm run build:prod
|
||||
|
||||
WORKDIR /src/main/resources
|
||||
RUN ls
|
||||
|
||||
WORKDIR /src/main/resources/static
|
||||
RUN ls
|
||||
|
||||
FROM nginx:alpine
|
||||
|
||||
ARG TZ=Asia/Shanghai
|
||||
|
||||
|
||||
COPY --from=builder /src/main/resources/static /opt/dist
|
||||
|
||||
CMD ["nginx","-g","daemon off;"]
|
||||
|
||||
11
docker/nginx/build.sh
Normal file
11
docker/nginx/build.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#/bin/bash
|
||||
set -e
|
||||
|
||||
version=2.7.3
|
||||
|
||||
rm ./dist/static/js/config.js
|
||||
cp ./config.js ./dist/static/js/
|
||||
|
||||
docker build -t polaris-nginx:${version} .
|
||||
docker tag polaris-nginx:${version} polaris-tian-docker.pkg.coding.net/qt/polaris/polaris-nginx:${version}
|
||||
docker tag polaris-nginx:${version} polaris-tian-docker.pkg.coding.net/qt/polaris/polaris-nginx:latest
|
||||
22
docker/nginx/config.js
Normal file
22
docker/nginx/config.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
window.baseUrl = "http://10.10.1.124:18978"
|
||||
|
||||
// map组件全局参数, 注释此内容可以关闭地图功能
|
||||
window.mapParam = {
|
||||
// 开启/关闭地图功能
|
||||
enable: true,
|
||||
// 坐标系 GCJ-02 WGS-84,
|
||||
coordinateSystem: "GCJ-02",
|
||||
// 地图瓦片地址
|
||||
tilesUrl: "http://webrd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8",
|
||||
// 瓦片大小
|
||||
tileSize: 256,
|
||||
// 默认层级
|
||||
zoom:10,
|
||||
// 默认地图中心点
|
||||
center:[116.41020, 39.915119],
|
||||
// 地图最大层级
|
||||
maxZoom:18,
|
||||
// 地图最小层级
|
||||
minZoom: 3
|
||||
}
|
||||
110
docker/nginx/templates/nginx.conf.template
Normal file
110
docker/nginx/templates/nginx.conf.template
Normal file
@@ -0,0 +1,110 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /opt/dist;
|
||||
index index.html index.htm;
|
||||
}
|
||||
location /record_proxy/{
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://polaris-wvp:18978/;
|
||||
}
|
||||
location /api/ {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://polaris-wvp:18978;
|
||||
|
||||
|
||||
# 从环境变量获取原始主机地址(x.x.x.x)
|
||||
set $original_host ${Stream_IP};
|
||||
|
||||
# 执行字符串替换
|
||||
# 将媒体资源文件替换为Nginx输出的相对地址
|
||||
sub_filter "http://$original_host/index/api/downloadFile" "mediaserver/api/downloadFile";
|
||||
sub_filter "http://$original_host:80/index/api/downloadFile" "mediaserver/api/downloadFile";
|
||||
sub_filter "https://$original_host/index/api/downloadFile" "mediaserver/api/downloadFile";
|
||||
sub_filter "https://$original_host:443/index/api/downloadFile" "mediaserver/api/downloadFile";
|
||||
sub_filter "http://$original_host/mp4_record" "mp4_record";
|
||||
sub_filter "http://$original_host:80/mp4_record" "mp4_record";
|
||||
sub_filter "https://$original_host/mp4_record" "mp4_record";
|
||||
sub_filter "https://$original_host:443/mp4_record" "mp4_record";
|
||||
|
||||
# 设置为off表示替换所有匹配项,而不仅仅是第一个
|
||||
sub_filter_once off;
|
||||
|
||||
# 确保响应被正确处理
|
||||
sub_filter_types application/json; # 只对JSON响应进行处理
|
||||
}
|
||||
|
||||
# 将mediaserver/record转发到目标地址
|
||||
location /mediaserver/api/downloadFile {
|
||||
# 目标服务器地址
|
||||
proxy_pass http://polaris-media:80/index/api/downloadFile;
|
||||
|
||||
# 以下是常用的反向代理设置
|
||||
proxy_set_header Host $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_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# 仅允许代理/rtp/开头的路径
|
||||
location ^~ /rtp/ {
|
||||
# 代理到ZLMediakit服务
|
||||
proxy_pass http://polaris-media:80;
|
||||
|
||||
# 基础HTTP代理配置
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# WebSocket支持配置
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# 超时设置,根据实际需求调整
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 60s;
|
||||
}
|
||||
|
||||
# 仅允许代理/rtp/开头的路径
|
||||
location ^~ /mp4_record/ {
|
||||
# 代理到ZLMediakit服务
|
||||
proxy_pass http://polaris-media:80;
|
||||
|
||||
# 基础HTTP代理配置
|
||||
proxy_set_header Host $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;
|
||||
|
||||
# WebSocket支持配置
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# 超时设置,根据实际需求调整
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 60s;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user