fix: 优化docker-entrypoint.sh替换为变量
This commit is contained in:
parent
2437dbb126
commit
acf2c006db
|
@ -8,12 +8,11 @@ if [ -z "$API_BASE_PATH" ]; then
|
||||||
API_BASE_PATH="http://jetlinks:8844/";
|
API_BASE_PATH="http://jetlinks:8844/";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
apiUrl="proxy_pass $API_BASE_PATH\$1;"
|
apiUrl="proxy_pass $API_BASE_PATH\$1;"
|
||||||
resolver="resolver $NAMESERVERS ipv6=off;"
|
resolver="resolver $NAMESERVERS ipv6=off;"
|
||||||
|
|
||||||
sed -i '11c '"$resolver"'' /etc/nginx/conf.d/default.conf
|
sed -i '11c '"$resolver"'' /etc/nginx/conf.d/default.conf
|
||||||
sed -i '25c '"$apiUrl"'' /etc/nginx/conf.d/default.conf
|
sed -i "s%{API_BASE_PATH}%$API_BASE_PATH%g" /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
if [ -z "$SERVER_NAME" ]; then
|
if [ -z "$SERVER_NAME" ]; then
|
||||||
serverName="server_name localhost;"
|
serverName="server_name localhost;"
|
||||||
|
@ -22,8 +21,10 @@ if [ -z "$SERVER_NAME" ]; then
|
||||||
else
|
else
|
||||||
serverName="server_name $SERVER_NAME;"
|
serverName="server_name $SERVER_NAME;"
|
||||||
sed -i '4c '"$serverName"'' /etc/nginx/conf.d/default.conf
|
sed -i '4c '"$serverName"'' /etc/nginx/conf.d/default.conf
|
||||||
sed -i 's/\${SERVER_NAME}/'$SERVER_NAME'/g' /etc/nginx/conf.d/default.conf
|
sed -i "s%{SERVER_NAME}%$SERVER_NAME%g" /etc/nginx/conf.d/default.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#cat /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
nginx -g "daemon off;"
|
nginx -g "daemon off;"
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ server {
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
|
|
||||||
if ($http_Host !~* ^${SERVER_NAME}) {
|
if ($http_Host !~* ^{SERVER_NAME}) {
|
||||||
return 403;
|
return 403;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ server {
|
||||||
|
|
||||||
location ^~/api/ {
|
location ^~/api/ {
|
||||||
if ($request_uri ~* ^/api/(.*)$) {
|
if ($request_uri ~* ^/api/(.*)$) {
|
||||||
proxy_pass http://host.docker.internal:8840/$1;
|
proxy_pass {API_BASE_PATH}$1;
|
||||||
}
|
}
|
||||||
#proxy_pass http://host.docker.internal:8840/;
|
#proxy_pass http://host.docker.internal:8840/;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
Loading…
Reference in New Issue