Skip to content

Commit

Permalink
Merge pull request #33 from reload/vite-and-more
Browse files Browse the repository at this point in the history
Vite
  • Loading branch information
arnested authored Dec 13, 2024
2 parents 2846018 + 98eacd9 commit b744066
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ FROM base AS proxy

COPY /proxy /

##
# Vite
##
FROM proxy AS vite

COPY /vite /

ENV NGINX_PROXY_PASS=http://app:5173

##
# NextJS
##
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ environment:
This nginx proxy comes with three predefined configurations:

- Proxy
- Vite
- Next.js
- Storybook
- Drupal
Expand All @@ -95,6 +96,26 @@ environment:
NGINX_PROXY_PASS: <no default>
```

### Vite

Vite is like the proxy configuration but also forwards all WebSocket
requests.

```yaml
image: ghcr.io/reload/https-proxy:vite
```

See the configuration details in
[`context/vite/etc/nginx/templates/default.conf.template`](context/nextjs/etc/vite/templates/default.conf.template).

Use can use the following configuration in your `docker-compose.yml`:

```yaml
environment:
NGINX_DOCUMENT_ROOT: /var/www/web
NGINX_PROXY_PASS: http://app:5173
```

### Next.js

Next.js is like the proxy configuration but also forwards WebSocket
Expand Down
3 changes: 3 additions & 0 deletions context/nextjs/etc/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ server {

location / {
proxy_pass ${NGINX_PROXY_PASS};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /_next/webpack-hmr {
Expand Down
3 changes: 3 additions & 0 deletions context/storybook/etc/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ server {

location / {
proxy_pass ${NGINX_PROXY_PASS};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /__webpack-hmr {
Expand Down
18 changes: 18 additions & 0 deletions context/vite/etc/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {

include include.d/ssl.conf;

root ${NGINX_DOCUMENT_ROOT};

location / {
proxy_pass ${NGINX_PROXY_PASS};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# WebSocket proxy
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_read_timeout 86400;
}
}

0 comments on commit b744066

Please sign in to comment.