1.8 KiB
1.8 KiB
DNS/CoreDNS를 설정한 뒤 진행했음
Install using docker
Directory structure
- /mnt/md0/infra
- /coredns
- 파일 생략
- /nginx
- /conf.d
- default.conf
- locations
- ns1.conf
- nginx.conf
- .env
- compose.yml
dotenv file
/.env
BASE_PATH=/mnt/md0/infra
Docker compose
/compose.yml
name: infrastructure
service:
nginx:
image: nginx:1.26-alpine3.20
container_name: nginx-reverse-proxy
restart: always
ports:
- 80:80
volumes:
- ${BASE_PATH}/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ${BASE_PATH}/nginx/conf.d:/etc/nginx/conf.d:ro
networks:
- infra
depends_on:
- dns
networks:
infra:
driver: bridge
nginx configuration
/nginx/nginx.conf
기본 설정 파일을 그대로 사용함
/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
error_page 404 500 502 053 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# 추후 다른 세팅을 쉽게 추가하기 위해 변경
include /etc/nginx/conf.d/locations/*.conf;
}
subdomain
server {
listen 80;
server_name gitea.home.server;
location / {
proxy_set_header Connection $http_connection;
proxy_set_header Upgrade $http_upgrade;
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_pass http://gitea:3000;
}
}
reload
docker exec -it webserver4 nginx -s reload