diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0d207b..8a3080a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,7 +110,31 @@ jobs: - run: docker logs $(docker ps -qn1) if: ${{ always() }} - nginx-webserver: + nginx-reverse-proxy: + name: nginx reverse proxy + X + runs-on: ubuntu-22.04 + strategy: + matrix: + config: + - nginx-reverse-proxy-public.conf + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + - 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: bash tests/await.sh http://localhost + - run: bash tests/integration.bash http://localhost + - run: docker stop $(docker ps -qn2) + - run: docker logs $(docker ps -qn1) + if: ${{ always() }} + - run: docker logs $(docker ps -qn2 | tail -n1) + if: ${{ always() }} + + nginx-fpm: name: nginx + PHP-FPM (PHP ${{ matrix.php }}) runs-on: ubuntu-22.04 strategy: diff --git a/docs/best-practices/deployment.md b/docs/best-practices/deployment.md index 8198898..d22ba7e 100644 --- a/docs/best-practices/deployment.md +++ b/docs/best-practices/deployment.md @@ -423,15 +423,24 @@ achieved by using an nginx configuration with the following contents: ``` server { - root /home/alice/projects/acme/public; - index index.php index.html; - + # Serve static files from `public/`, proxy dynamic requests to Framework X location / { - try_files $uri $uri/ @x; + 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; } } ``` diff --git a/tests/integration/nginx-reverse-proxy-public.conf b/tests/integration/nginx-reverse-proxy-public.conf new file mode 100644 index 0000000..0b53e39 --- /dev/null +++ b/tests/integration/nginx-reverse-proxy-public.conf @@ -0,0 +1,21 @@ +server { + # Serve static files from `public/`, proxy dynamic requests to Framework X + location / { + location ~* \.php$ { + try_files /dev/null @x; + } + root /home/framework-x/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; + } +}