diff --git a/docker/proxy/Dockerfile b/docker/proxy/Dockerfile index 48aab8f3..8bbdeaca 100644 --- a/docker/proxy/Dockerfile +++ b/docker/proxy/Dockerfile @@ -1,4 +1,4 @@ -# modify time: 202311041640, you can modify here to trigger Docker Build action +# modify time: 202311071141, you can modify here to trigger Docker Build action # from Dockerfile: https://github.com/NginxProxyManager/nginx-proxy-manager/blob/develop/docker/Dockerfile # from image: https://hub.docker.com/r/jc21/nginx-proxy-manager diff --git a/docker/proxy/config/initproxy.conf b/docker/proxy/config/initproxy.conf index 23f79b9b..b51b4283 100644 --- a/docker/proxy/config/initproxy.conf +++ b/docker/proxy/config/initproxy.conf @@ -102,13 +102,19 @@ server { } } - location /api/ { + location /api/ { proxy_pass http://websoft9-apphub:8080/; 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_set_header X-Forwarded-Proto $scheme; + add_header 'Access-Control-Allow-Origin' $http_origin; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-api-key'; + if ($request_method = OPTIONS) { + return 204; + } + } location /media/ { proxy_pass http://websoft9-apphub:8081/images/; diff --git a/install/install_cockpit.sh b/install/install_cockpit.sh index 3e07d81f..61a3919e 100644 --- a/install/install_cockpit.sh +++ b/install/install_cockpit.sh @@ -319,25 +319,21 @@ Install_Cockpit(){ apt_status=$? if [ $dnf_status -eq 0 ]; then - sudo dnf check-update - sudo dnf upgrade -y for pkg in $cockpit_packages do - echo "Installing $pkg" - sudo dnf install -y "$pkg" || echo "$pkg failed to install" + echo "Install or upgrade $pkg" + sudo dnf upgrade -y "$pkg" || sudo dnf install -y "$pkg" || echo "$pkg failed to install or upgrade" done elif [ $yum_status -eq 0 ]; then - sudo yum check-update - sudo yum update -y for pkg in $cockpit_packages do - echo "Installing $pkg" - sudo yum install -y "$pkg" || echo "$pkg failed to install" + echo "Install or update $pkg" + sudo yum update -y "$pkg" || sudo yum install -y "$pkg" || echo "$pkg failed to install or update" done elif [ $apt_status -eq 0 ]; then export DEBIAN_FRONTEND=noninteractive sudo dpkg --configure -a - apt update -y + apt update -y >/dev/null 2>&1 apt --fix-broken install for pkg in $cockpit_packages do diff --git a/install/install_docker.sh b/install/install_docker.sh index 334c1334..039efda4 100644 --- a/install/install_docker.sh +++ b/install/install_docker.sh @@ -65,7 +65,7 @@ Install_Docker(){ # For CentOS, Fedora, or RHEL(only s390x) if [[ $(cat /etc/redhat-release) =~ "RHEL" ]] && [[ $(uname -m) == "s390x" ]] || [[ $(cat /etc/redhat-release) =~ "CentOS" ]] || [[ $(cat /etc/redhat-release) =~ "Fedora" ]]; then curl -fsSL https://get.docker.com -o get-docker.sh - timeout $timeout sh get-docker.sh --mirror $mirror + timeout $timeout sh get-docker.sh --channel stable --mirror $mirror else # For other distributions sudo yum install yum-utils -y > /dev/null @@ -78,7 +78,7 @@ Install_Docker(){ if type apt >/dev/null 2>&1; then # Wait for apt to be unlocked curl -fsSL https://get.docker.com -o get-docker.sh - timeout $timeout sh get-docker.sh --mirror $mirror + timeout $timeout sh get-docker.sh --channel stable --mirror $mirror fi } diff --git a/systemd/script/set_hosts.sh b/systemd/script/set_hosts.sh deleted file mode 100644 index 156d35ba..00000000 --- a/systemd/script/set_hosts.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# Define PATH -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -# Export PATH - -set -e - -# 容器名称 -container_name="websoft9-apphub" - -# 最大尝试次数 -max_attempts=6 - -# 获取容器的内网IP -attempt=0 -while [ $attempt -lt $max_attempts ]; do - container_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container_name) - - if [ -n "$container_ip" ]; then - break - fi - - attempt=$(( $attempt + 1 )) - sleep 5 -done - -# 检查获取IP是否成功 -if [ -z "$container_ip" ]; then - echo "Failed to get IP for container $container_name after $max_attempts attempts" - exit 1 -fi - -# 检查 /etc/hosts 文件中是否已经存在一个条目与容器名称相同 -if grep -q $container_name /etc/hosts; then - # 如果存在,使用 sed 命令更新这个条目 - sed -i "/$container_name/d" /etc/hosts - echo "$container_ip $container_name" | tee -a /etc/hosts > /dev/null - echo "Container $container_name IP updated to $container_ip in /etc/hosts" -else - # 如果不存在,添加一个新的条目 - echo "$container_ip $container_name" | tee -a /etc/hosts > /dev/null - echo "Container $container_name IP $container_ip added to /etc/hosts" -fi diff --git a/systemd/script/start_up.sh b/systemd/script/start_up.sh index 061d4d73..3efe65ea 100644 --- a/systemd/script/start_up.sh +++ b/systemd/script/start_up.sh @@ -1,5 +1,4 @@ #!/bin/bash /bin/bash send_credentials.sh -/bin/bash set_hosts.sh /bin/bash crontab.sh \ No newline at end of file