31 lines
1.0 KiB
Bash
31 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# 改用 172.19.0.1 (openresty 容器的 default gateway, = 宿主 IP)
|
|
NGINX_SITE=/etc/nginx/sites-enabled/yuyueguahao
|
|
|
|
# 替换所有 127.0.0.1:3000 为 172.19.0.1:3000
|
|
sed -i 's|127.0.0.1:3000|172.19.0.1:3000|g' "$NGINX_SITE"
|
|
|
|
echo "--- Updated /uploads/ ---"
|
|
grep -A2 'location /uploads' "$NGINX_SITE"
|
|
echo ""
|
|
echo "--- Updated /api/ ---"
|
|
grep -A2 'location /api' "$NGINX_SITE"
|
|
|
|
# Test config + reload
|
|
nginx -t 2>&1 | tail -2
|
|
NGINX_MASTER=$(ps -efL | grep "nginx: master" | grep -v grep | awk '{print $2}' | head -1)
|
|
echo "Master: $NGINX_MASTER"
|
|
kill -HUP "$NGINX_MASTER"
|
|
sleep 2
|
|
|
|
# Test
|
|
echo "--- TEST uploads (port 80) ---"
|
|
curl -o /dev/null -s -w "HTTP %{http_code} size=%{size_download} type=%{content_type}\n" http://localhost/uploads/1781403331659-1cac3cac.png
|
|
echo "--- TEST api (port 80) ---"
|
|
curl -o /dev/null -s -w "HTTP %{http_code}\n" http://localhost/api/v1/banners
|
|
echo "--- TEST home (port 80) ---"
|
|
curl -o /dev/null -s -w "HTTP %{http_code}\n" http://localhost/
|
|
|
|
# Save the IP for future use
|
|
echo "172.19.0.1" > /tmp/host-ip.txt
|