92 lines
1.8 KiB
Markdown
92 lines
1.8 KiB
Markdown
[[DNS/CoreDNS|CoreDNS]]를 설정한 뒤 진행했음
|
|
|
|
# 1. Install using docker
|
|
## 1.1. Directory structure
|
|
```dirtree
|
|
- /mnt/md0/infra
|
|
- /coredns
|
|
- 파일 생략
|
|
- /nginx
|
|
- /conf.d
|
|
- default.conf
|
|
- locations
|
|
- ns1.conf
|
|
- nginx.conf
|
|
- .env
|
|
- compose.yml
|
|
```
|
|
|
|
## 1.2. dotenv file
|
|
/.env
|
|
```
|
|
BASE_PATH=/mnt/md0/infra
|
|
```
|
|
|
|
## 1.3. Docker compose
|
|
/compose.yml
|
|
```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
|
|
```
|
|
|
|
# 2. nginx configuration
|
|
## 2.1. /nginx/nginx.conf
|
|
기본 설정 파일을 그대로 사용함
|
|
|
|
## 2.2. /nginx/conf.d/default.conf
|
|
|
|
```nginx
|
|
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;
|
|
}
|
|
```
|
|
|
|
## 2.3. subdomain
|
|
|
|
```nginx
|
|
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;
|
|
}
|
|
}
|
|
```
|
|
|
|
## 2.4. reload
|
|
|
|
```shell
|
|
docker exec -it nginx-reverse-proxy nginx -s reload
|
|
``` |