Skip to content

Instantly share code, notes, and snippets.

@overnew
Created April 21, 2024 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save overnew/86cf63b055e7d67146df2adbaf805137 to your computer and use it in GitHub Desktop.
Save overnew/86cf63b055e7d67146df2adbaf805137 to your computer and use it in GitHub Desktop.
web_userdata
#!/bin/bash
# Nginx 설치
apt update
apt install -y nginx
index_file="/var/www/html/index.html"
cat <<EOF > $index_file
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Jin</title>
</head>
<body>
<h1>Welcome to WEB</h1>
<p>Hello, this is a simple webpage served by Nginx.</p>
<a href="/was">Go to was Page</a>
</body>
</html>
EOF
systemctl start nginx
# Nginx 설정 파일 열기
nginx_config="/etc/nginx/sites-available/default"
# Nginx 프록시 설정 추가
cat <<EOF > $nginx_config
server {
listen 80;
server_name babo;
location /was {
proxy_pass http://internal-3-tier-app-alb-2072048027.ap-northeast-2.elb.amazonaws.com/;
}
}
EOF
# 설정 적용 및 Nginx 재시작
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
nginx -t && systemctl reload nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment