Skip to content

Commit 71c104a

Browse files
authored
Merge pull request #30 from erseco/29-load-additional-nginx-configurations-inside-the-server-block-for-easier-customization
29 load additional nginx configurations inside the server block for easier customization
2 parents f848cd1 + 3d583cb commit 71c104a

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.aider*
2+
.env

README.md

+26-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,31 @@ The following example shows how you can add a startup script. This script simply
106106
ADD logtime.sh /docker-entrypoint-init.d/logtime.sh
107107

108108

109-
## Configuration
109+
## Nginx Configuration
110+
111+
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`.
112+
113+
### Adding Custom Configurations
114+
115+
You can add custom configurations in two ways:
116+
117+
1. **Global Configurations**: Place your configuration files in `/etc/nginx/conf.d/`. These configurations are included globally and affect all server blocks.
118+
119+
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.
120+
121+
### Example
122+
123+
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:
124+
125+
```nginx
126+
# Example custom server configuration
127+
location /custom {
128+
return 200 'Custom server configuration is working!';
129+
add_header Content-Type text/plain;
130+
}
131+
```
132+
133+
This setup allows you to easily manage and customize your Nginx configurations without modifying the main `nginx.conf` file.
110134
In [rootfs/etc/](rootfs/etc/) you'll find the default configuration files for Nginx, PHP and PHP-FPM.
111135
If you want to extend or customize that you can do so by mounting a configuration file in the correct folder;
112136

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

192216
```bash
193217
docker-compose exec --user root alpine-php-webserver sh
194-
```
218+
```

rootfs/etc/nginx/nginx.conf

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ http {
103103
include fastcgi_params;
104104
fastcgi_pass unix:/run/php-fpm.sock;
105105
}
106+
107+
# Include additional server-specific configurations
108+
include /etc/nginx/server-conf.d/*.conf;
109+
106110
}
107111

108112
# Include other server configs

0 commit comments

Comments
 (0)