nginx config fixed

This commit is contained in:
qiaofeng1227 2023-11-07 11:43:43 +08:00
parent 8ce9692c7d
commit 605362010e
6 changed files with 17 additions and 59 deletions

View file

@ -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

View file

@ -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/;

View file

@ -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

View file

@ -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
}

View file

@ -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

View file

@ -1,5 +1,4 @@
#!/bin/bash
/bin/bash send_credentials.sh
/bin/bash set_hosts.sh
/bin/bash crontab.sh