Skip to content

Commit

Permalink
Add minimal nginx reverse proxy configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Mar 5, 2024
1 parent 9c852e9 commit 9f324ab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ jobs:
if: ${{ always() }}

nginx-reverse-proxy:
name: nginx reverse proxy + X
name: nginx reverse proxy + X (${{ matrix.config.name }})
runs-on: ubuntu-22.04
strategy:
matrix:
config:
- nginx-reverse-proxy-public.conf
- name: with files
path: nginx-reverse-proxy-public.conf
- name: minimal
path: nginx-reverse-proxy-minimal.conf
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
Expand All @@ -125,7 +128,7 @@ jobs:
- run: composer install -d tests/integration/
- run: docker build -f tests/integration/Dockerfile-basics tests/integration/
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json $(docker images -q | head -n1)
- 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
- 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
- run: bash tests/await.sh http://localhost
- run: bash tests/integration.bash http://localhost
- run: docker stop $(docker ps -qn2)
Expand Down
49 changes: 32 additions & 17 deletions docs/best-practices/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,29 +421,44 @@ all you need to do is to point the nginx' [`root`](http://nginx.org/en/docs/http
to instruct nginx to process any dynamic requests through X. This can be
achieved by using an nginx configuration with the following contents:

```
server {
# Serve static files from `public/`, proxy dynamic requests to Framework X
location / {
location ~* \.php$ {
=== "nginx.conf (reverse proxy with static files)"

```
server {
# Serve static files from `public/`, proxy dynamic requests to Framework X
location / {
location ~* \.php$ {
try_files /dev/null @x;
}
root /home/alice/projects/acme/public;
try_files $uri @x;
}

location @x {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header Connection "";
}

# Optional: handle Apache config with Framework X if it exists in `public/`
location ~ \.htaccess$ {
try_files /dev/null @x;
}
root /home/alice/projects/acme/public;
try_files $uri @x;
}
```

location @x {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header Connection "";
}
=== "nginx.conf (minimal reverse proxy)"

# Optional: handle Apache config with Framework X if it exists in `public/`
location ~ \.htaccess$ {
try_files /dev/null @x;
```
server {
# Proxy all requests to Framework X
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header Connection "";
}
}
}
```
```

> ℹ️ **New to nginx?**
>
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/nginx-reverse-proxy-minimal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
# Proxy all requests to Framework X
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header Connection "";
}
}

0 comments on commit 9f324ab

Please sign in to comment.