Skip to content

Commit b744066

Browse files
authored
Merge pull request #33 from reload/vite-and-more
Vite
2 parents 2846018 + 98eacd9 commit b744066

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ FROM base AS proxy
3535

3636
COPY /proxy /
3737

38+
##
39+
# Vite
40+
##
41+
FROM proxy AS vite
42+
43+
COPY /vite /
44+
45+
ENV NGINX_PROXY_PASS=http://app:5173
46+
3847
##
3948
# NextJS
4049
##

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ environment:
7171
This nginx proxy comes with three predefined configurations:
7272

7373
- Proxy
74+
- Vite
7475
- Next.js
7576
- Storybook
7677
- Drupal
@@ -95,6 +96,26 @@ environment:
9596
NGINX_PROXY_PASS: <no default>
9697
```
9798

99+
### Vite
100+
101+
Vite is like the proxy configuration but also forwards all WebSocket
102+
requests.
103+
104+
```yaml
105+
image: ghcr.io/reload/https-proxy:vite
106+
```
107+
108+
See the configuration details in
109+
[`context/vite/etc/nginx/templates/default.conf.template`](context/nextjs/etc/vite/templates/default.conf.template).
110+
111+
Use can use the following configuration in your `docker-compose.yml`:
112+
113+
```yaml
114+
environment:
115+
NGINX_DOCUMENT_ROOT: /var/www/web
116+
NGINX_PROXY_PASS: http://app:5173
117+
```
118+
98119
### Next.js
99120

100121
Next.js is like the proxy configuration but also forwards WebSocket

context/nextjs/etc/nginx/templates/default.conf.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ server {
66

77
location / {
88
proxy_pass ${NGINX_PROXY_PASS};
9+
proxy_set_header Host $host;
10+
proxy_set_header X-Real-IP $remote_addr;
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
912
}
1013

1114
location /_next/webpack-hmr {

context/storybook/etc/nginx/templates/default.conf.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ server {
66

77
location / {
88
proxy_pass ${NGINX_PROXY_PASS};
9+
proxy_set_header Host $host;
10+
proxy_set_header X-Real-IP $remote_addr;
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
912
}
1013

1114
location /__webpack-hmr {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
3+
include include.d/ssl.conf;
4+
5+
root ${NGINX_DOCUMENT_ROOT};
6+
7+
location / {
8+
proxy_pass ${NGINX_PROXY_PASS};
9+
proxy_set_header Host $host;
10+
proxy_set_header X-Real-IP $remote_addr;
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+
13+
# WebSocket proxy
14+
proxy_set_header Upgrade $http_upgrade;
15+
proxy_set_header Connection "Upgrade";
16+
proxy_read_timeout 86400;
17+
}
18+
}

0 commit comments

Comments
 (0)