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/";
|
||||
fi
|
||||
|
||||
|
||||
apiUrl="proxy_pass $API_BASE_PATH\$1;"
|
||||
resolver="resolver $NAMESERVERS ipv6=off;"
|
||||
|
||||
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
|
||||
serverName="server_name localhost;"
|
||||
|
@ -22,8 +21,10 @@ if [ -z "$SERVER_NAME" ]; then
|
|||
else
|
||||
serverName="server_name $SERVER_NAME;"
|
||||
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
|
||||
|
||||
#cat /etc/nginx/conf.d/default.conf
|
||||
|
||||
nginx -g "daemon off;"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ server {
|
|||
root /usr/share/nginx/html;
|
||||
include /etc/nginx/mime.types;
|
||||
|
||||
if ($http_Host !~* ^${SERVER_NAME}) {
|
||||
if ($http_Host !~* ^{SERVER_NAME}) {
|
||||
return 403;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ server {
|
|||
|
||||
location ^~/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_set_header X-Forwarded-Proto $scheme;
|
||||
|
|
Loading…
Reference in New Issue