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 1e335dc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
7 changes: 5 additions & 2 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 public/
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 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 1e335dc

Please sign in to comment.