From 1e335dcae858f8f13e4d4e1a44b7144c8be53f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Fri, 1 Mar 2024 19:31:05 +0100 Subject: [PATCH] Add minimal nginx reverse proxy configuration --- .github/workflows/ci.yml | 7 ++- docs/best-practices/deployment.md | 49 ++++++++++++------- .../nginx-reverse-proxy-minimal.conf | 8 +++ 3 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 tests/integration/nginx-reverse-proxy-minimal.conf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a3080a..c6a9d6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/docs/best-practices/deployment.md b/docs/best-practices/deployment.md index d22ba7e..62ca3a1 100644 --- a/docs/best-practices/deployment.md +++ b/docs/best-practices/deployment.md @@ -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?** > diff --git a/tests/integration/nginx-reverse-proxy-minimal.conf b/tests/integration/nginx-reverse-proxy-minimal.conf new file mode 100644 index 0000000..90f024f --- /dev/null +++ b/tests/integration/nginx-reverse-proxy-minimal.conf @@ -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 ""; + } +}