Skip to content

Commit 99d43a5

Browse files
committed
Add minimal nginx reverse proxy configuration
1 parent 9c852e9 commit 99d43a5

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ jobs:
111111
if: ${{ always() }}
112112

113113
nginx-reverse-proxy:
114-
name: nginx reverse proxy + X
114+
name: nginx (${{ matrix.config.name }})
115115
runs-on: ubuntu-22.04
116116
strategy:
117117
matrix:
118118
config:
119-
- nginx-reverse-proxy-public.conf
119+
- name: reverse proxy with files
120+
path: nginx-reverse-proxy-public.conf
121+
- name: minimal reverse proxy
122+
path: nginx-reverse-proxy-minimal.conf
120123
steps:
121124
- uses: actions/checkout@v4
122125
- uses: shivammathur/setup-php@v2
@@ -125,7 +128,7 @@ jobs:
125128
- run: composer install -d tests/integration/
126129
- run: docker build -f tests/integration/Dockerfile-basics tests/integration/
127130
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json $(docker images -q | head -n1)
128-
- run: docker run -d --net=host -v "$PWD/tests/integration/":/home/framework-x/ -v "$PWD"/tests/integration/${{ matrix.config }}:/etc/nginx/conf.d/default.conf nginx:stable-alpine
131+
- run: docker run -d --net=host -v "$PWD/tests/integration/":/home/framework-x/ -v "$PWD"/tests/integration/${{ matrix.config.path }}:/etc/nginx/conf.d/default.conf nginx:stable-alpine
129132
- run: bash tests/await.sh http://localhost
130133
- run: bash tests/integration.bash http://localhost
131134
- run: docker stop $(docker ps -qn2)

docs/best-practices/deployment.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -421,29 +421,44 @@ all you need to do is to point the nginx' [`root`](http://nginx.org/en/docs/http
421421
to instruct nginx to process any dynamic requests through X. This can be
422422
achieved by using an nginx configuration with the following contents:
423423

424-
```
425-
server {
426-
# Serve static files from `public/`, proxy dynamic requests to Framework X
427-
location / {
428-
location ~* \.php$ {
424+
=== "nginx.conf (reverse proxy with static files)"
425+
426+
```
427+
server {
428+
# Serve static files from `public/`, proxy dynamic requests to Framework X
429+
location / {
430+
location ~* \.php$ {
431+
try_files /dev/null @x;
432+
}
433+
root /home/alice/projects/acme/public;
434+
try_files $uri @x;
435+
}
436+
437+
location @x {
438+
proxy_pass http://localhost:8080;
439+
proxy_set_header Host $host;
440+
proxy_set_header Connection "";
441+
}
442+
443+
# Optional: handle Apache config with Framework X if it exists in `public/`
444+
location ~ \.htaccess$ {
429445
try_files /dev/null @x;
430446
}
431-
root /home/alice/projects/acme/public;
432-
try_files $uri @x;
433447
}
448+
```
434449

435-
location @x {
436-
proxy_pass http://localhost:8080;
437-
proxy_set_header Host $host;
438-
proxy_set_header Connection "";
439-
}
450+
=== "nginx.conf (minimal reverse proxy)"
440451

441-
# Optional: handle Apache config with Framework X if it exists in `public/`
442-
location ~ \.htaccess$ {
443-
try_files /dev/null @x;
452+
```
453+
server {
454+
# Proxy all requests to Framework X
455+
location / {
456+
proxy_pass http://localhost:8080;
457+
proxy_set_header Host $host;
458+
proxy_set_header Connection "";
459+
}
444460
}
445-
}
446-
```
461+
```
447462

448463
> ℹ️ **New to nginx?**
449464
>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
server {
2+
# Proxy all requests to Framework X
3+
location / {
4+
proxy_pass http://localhost:8080;
5+
proxy_set_header Host $host;
6+
proxy_set_header Connection "";
7+
}
8+
}

0 commit comments

Comments
 (0)