Skip to content

Commit

Permalink
Merge pull request #30 from erseco/29-load-additional-nginx-configura…
Browse files Browse the repository at this point in the history
…tions-inside-the-server-block-for-easier-customization

29 load additional nginx configurations inside the server block for easier customization
  • Loading branch information
erseco authored Nov 7, 2024
2 parents f848cd1 + 3d583cb commit 71c104a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.aider*
.env
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,31 @@ The following example shows how you can add a startup script. This script simply
ADD logtime.sh /docker-entrypoint-init.d/logtime.sh


## Configuration
## Nginx Configuration

The Nginx configuration is designed to be flexible and easy to customize. By default, the main configuration file is located at `rootfs/etc/nginx/nginx.conf`.

### Adding Custom Configurations

You can add custom configurations in two ways:

1. **Global Configurations**: Place your configuration files in `/etc/nginx/conf.d/`. These configurations are included globally and affect all server blocks.

2. **Server-Specific Configurations**: For configurations specific to a particular server block, place your files in `/etc/nginx/server-conf.d/`. These are included within the server block, allowing for more granular control.

### Example

To add a custom configuration, create a `.conf` file in the appropriate directory. For example, to add a server-specific rule, you might create a file named `custom-server.conf` in `/etc/nginx/server-conf.d/` with the following content:

```nginx
# Example custom server configuration
location /custom {
return 200 'Custom server configuration is working!';
add_header Content-Type text/plain;
}
```

This setup allows you to easily manage and customize your Nginx configurations without modifying the main `nginx.conf` file.
In [rootfs/etc/](rootfs/etc/) you'll find the default configuration files for Nginx, PHP and PHP-FPM.
If you want to extend or customize that you can do so by mounting a configuration file in the correct folder;

Expand Down Expand Up @@ -191,4 +215,4 @@ In certain situations, you might need to run commands as `root` within your Mood

```bash
docker-compose exec --user root alpine-php-webserver sh
```
```
4 changes: 4 additions & 0 deletions rootfs/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ http {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm.sock;
}

# Include additional server-specific configurations
include /etc/nginx/server-conf.d/*.conf;

}

# Include other server configs
Expand Down

0 comments on commit 71c104a

Please sign in to comment.