Skip to content

Commit

Permalink
Update nginx configuration to handle FRP subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhao98 committed Mar 5, 2024
1 parent ec7d2ab commit 031ae7b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 7 additions & 1 deletion rootfs-s6-rc/etc/s6-overlay/s6-rc.d/20-nginx/run
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ sed -i "s/REPLACE_SERVER_IP/${SERVER_IP}/g" /usr/share/nginx/html/client.sh
sed -i "s/REPLACE_VERSION/${FRPS_VER}/g" /usr/share/nginx/html/client.sh

sed -i "s/REPLACE_MAIN_DOMAIN/${FRP_SUBDOMAIN_HOST}/g" /usr/share/nginx/html/client.vbs
sed -i "s/REPLACE_MAIN_DOMAIN/${FRP_SUBDOMAIN_HOST}/g" /usr/share/nginx/html/client.cmd
sed -i "s/REPLACE_SERVER_IP/${SERVER_IP}/g" /usr/share/nginx/html/client.vbs
sed -i "s/REPLACE_VERSION/${FRPS_VER}/g" /usr/share/nginx/html/client.vbs

# 如果 FRP_SUBDOMAIN_HOST 是 n 开头,先把 default.conf.template 文件中的 `REPLACE_MAIN_DOMAIN_frp_client` 替换成 `\REPLACE_MAIN_DOMAIN_frp_client`
if [[ ${FRP_SUBDOMAIN_HOST} == n* ]]; then
sed -i "s/REPLACE_MAIN_DOMAIN_frp_client/\\\\REPLACE_MAIN_DOMAIN_frp_client/g" /etc/nginx/templates/default.conf.template
fi

sed -i "s/REPLACE_MAIN_DOMAIN/${FRP_SUBDOMAIN_HOST}/g" /etc/nginx/templates/default.conf.template

exec /docker-entrypoint-nginx.sh nginx -g 'daemon off;'
6 changes: 3 additions & 3 deletions rootfs/etc/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ server {
rewrite ^/dash/(.*)$ /static/$1 break;
}

# location /client.cmd {
# return 200 "cls && curl -s ${FRP_SUBDOMAIN_HOST}/client.vbs -o %temp%\${FRP_SUBDOMAIN_HOST}_frp_client.vbs && cscript %temp%\${FRP_SUBDOMAIN_HOST}_frp_client.vbs $args\n";
# }
location /client.cmd {
return 200 "cls && curl -s REPLACE_MAIN_DOMAIN/client.vbs -o %temp%\REPLACE_MAIN_DOMAIN_frp_client.vbs && cscript %temp%\REPLACE_MAIN_DOMAIN_frp_client.vbs $args\n";
}
}

server {
Expand Down
1 change: 0 additions & 1 deletion rootfs/usr/share/nginx/html/client.cmd

This file was deleted.

0 comments on commit 031ae7b

Please sign in to comment.