Skip to content

Support custom routing engine #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ ENV client_max_body_size=2M \
opcache_jit=1235 \
opcache_memory_consumption=128 \
opcache_interned_strings_buffer=16 \
opcache_max_accelerated_files=15000
opcache_max_accelerated_files=15000 \
custom_router=''

# List of config files that will be updated with environment variables using envsubst
ENV envsubst_config_list="/etc/nginx/nginx.conf \
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ You can define the below environment variables to change values from NGINX and P

| Server | Variable Name | Default | Description |
|--------|---------------------------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| * | envsubst_config_list | See above | Sets the list of config files to be updsted with ENV variables |
| * | envsubst_config_list | See above | Sets the list of config files to be updated with ENV variables |
| NGINX | custom_router | | Set custom routing engine before the fallback to index.php |
| NGINX | client_max_body_size | 2m | Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. |
| PHP8 | clear_env | no | Clear environment in FPM workers. Prevents arbitrary environment variables from reaching FPM worker processes by clearing the environment in workers before env vars specified in this pool configuration are added. |
| PHP8 | allow_url_fopen | On | Enable the URL-aware fopen wrappers that enable accessing URL object like files. Default wrappers are provided for the access of remote files using the ftp or http protocol, some extensions like zlib may register additional wrappers. |
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ services:
app:
image: ${TEST_IMAGE_NAME:-jimsihk/alpine-php-nginx:local}
build: .
environment:
- custom_router=/r.php
sut:
image: ${TEST_IMAGE_NAME:-jimsihk/alpine-php-nginx:local}
depends_on:
- app
command: /tmp/run_tests.sh
volumes:
- "./run_tests.sh:/tmp/run_tests.sh:ro"
- "./run_tests.sh:/tmp/run_tests.sh:ro"
5 changes: 3 additions & 2 deletions rootfs/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ http {

location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.php
try_files $uri $uri/ /index.php$is_args$args;
# as directory, then custom routing engine (if defined),
# finally fall back to index.php
try_files $uri $uri/ ${custom_router} /index.php$is_args$args;
}

# Redirect server error pages to the static page /50x.html
Expand Down