Skip to content

Commit f4ae190

Browse files
committed
wip
1 parent 1c1846f commit f4ae190

11 files changed

Lines changed: 760 additions & 0 deletions

nginx/load-balancing/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```
2+
npm install
3+
npm run dev
4+
```
5+
6+
```
7+
open http://localhost:3000
8+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:22-alpine
2+
3+
WORKDIR /app
4+
5+
COPY . .
6+
7+
RUN npm install
8+
9+
RUN npm run build
10+
11+
CMD ["node", "dist/index.js"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx:alpine
2+
3+
COPY nginx-load-balancing.conf /etc/nginx/nginx.conf
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
app:
2+
name: load-balanced-nginx-ingress
3+
namespace: samples
4+
mode:
5+
flash:
6+
timeout: 1
7+
strategy: first-listen
8+
build:
9+
docker:
10+
dockerfile: load-balanced-ingress.dockerfile
11+
context: .
12+
resources:
13+
cpu: 1
14+
memory: 64
15+
expose:
16+
access:
17+
port: 80
18+
external:
19+
protocol: https
20+
connection-tracking:
21+
traffic-aware:
22+
inactivity-timeout: 3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
app:
2+
name: "load-balanced-hono-api-${{ var.idx }}"
3+
namespace: samples
4+
mode:
5+
flash:
6+
timeout: 1
7+
strategy: first-listen
8+
build:
9+
docker:
10+
dockerfile: load-balanced-hono-api.dockerfile
11+
context: .
12+
environment:
13+
IDX: "'${{ var.idx }}'"
14+
resources:
15+
cpu: 1
16+
memory: 64
17+
expose:
18+
access:
19+
internal:
20+
port: 3000
21+
port: 3000
22+
connection-tracking: connection-aware
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
upstream api {
7+
server load-balanced-hono-api-1-access.samples.svc.lttle.local:3000;
8+
server load-balanced-hono-api-2-access.samples.svc.lttle.local:3000;
9+
}
10+
11+
server {
12+
listen 80;
13+
server_name _;
14+
15+
location / {
16+
proxy_pass http://api;
17+
18+
# proxy_set_header Host $host;
19+
# proxy_set_header X-Real-IP $remote_addr;
20+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21+
# proxy_set_header X-Forwarded-Proto $scheme;
22+
}
23+
}
24+
}

nginx/load-balancing/node-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare namespace NodeJs {
2+
interface ProcessEnv {
3+
IDX: string;
4+
}
5+
}

0 commit comments

Comments
 (0)