Skip to content

Commit 3c49b61

Browse files
author
Alan
committed
change docker
1 parent 8702d22 commit 3c49b61

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: "3.7"
22

33
services:
4-
api:
5-
container_name: "api"
4+
docker-fastapi:
5+
container_name: "docker-fastapi"
66
build:
77
context: .
88
dockerfile: ./docker/api/Dockerfile
@@ -12,11 +12,11 @@ services:
1212
- 8080:8080
1313

1414
nginx:
15-
container_name: "nginx"
15+
container_name: "proxy-app"
1616
build:
1717
context: .
1818
dockerfile: ./docker/nginx/Dockerfile
1919
ports:
2020
- 80:80
2121
depends_on:
22-
- api
22+
- docker-fastapi

docker/nginx/nginx.conf

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
upstream docker_fastapi {
2+
server docker-fastapi:8080;
3+
}
4+
15
server {
2-
listen 80;
6+
listen 80;
37

4-
location / {
5-
root /usr/share/nginx/html;
6-
index index.html index.htm;
7-
try_files $uri $uri/ /index.html;
8-
}
8+
location ~ /api/ {
9+
proxy_pass http://docker_fastapi;
10+
proxy_set_header Host $host;
11+
proxy_set_header X-Real-IP $remote_addr;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_set_header X-Forwarded-Host $server_name;
14+
}
915

10-
location /api/v1/ {
11-
proxy_pass http://api:8080/;
12-
}
16+
location / {
17+
root /usr/share/nginx/html;
18+
index index.html index.htm;
19+
try_files $uri $uri/ /index.html;
20+
}
1321

14-
error_page 500 502 503 504 /50x.html;
15-
location = /50x.html {
16-
root /usr/share/nginx/html;
17-
}
22+
error_page 500 502 503 504 /50x.html;
1823

24+
location = /50x.html {
25+
root /usr/share/nginx/html;
26+
}
1927
}

0 commit comments

Comments
 (0)