Skip to content

Commit 6ab0cfb

Browse files
Merge pull request #297 from HOSTED-POWER/enhance-nginx-docs
Enhanced the Nginx docs
2 parents 191ed6f + 0092d6b commit 6ab0cfb

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

Technologies/Web Servers/NGINX/nginx_basics.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,30 @@ hidden: true
77
Our implementation of NGINX offers you the possibility to modify its configuration to your application-specific needs. To do so, you can place **custom NGINX configs** in a per-application directory under:
88

99
```bash
10-
/nginx
10+
~/nginx/
1111
```
1212

1313
This approach allows you to extend or override server behavior safely without interfering with the main system configs.
1414

15+
Example directory tree of an nginx folder with __Varnish caching__ enabled:
16+
17+
```bash
18+
nginx/
19+
├── 20rewrites.conf
20+
├── 50main.conf
21+
└── outside
22+
└── main
23+
└── 20rewrites.conf
24+
```
25+
1526
---
1627

28+
## Application Type
29+
30+
When you set an app type in our **TurboStack GUI**, our automation will create a default nginx config you can start from. If you ever want to start your config from scratch again, you can always remove the contents of the `~/nginx` directory and run a Full Publish via the GUI. This will place the default nginx config back in the `~/nginx` directory for your app type.
31+
32+
**Note:** A full publish will never overwrite your **existing** Nginx config files.
33+
1734
## Load Order of Config Files
1835

1936
NGINX processes config files in **alphabetical order**. This is important when deciding how to name your files.
@@ -33,10 +50,10 @@ Since files are loaded alphabetically, anything you add with a **higher prefix n
3350

3451
In case Varnish is enabled on your server, it sits in front of NGINX on our TurboStack. Your config placement determines whether it runs **before** or **after** Varnish:
3552

36-
- **Inside `/nginx`**
53+
- **Inside `~/nginx`**
3754
→ Files here are loaded **after Varnish**. This is ideal for app-level rewrites, caching rules, or security headers.
3855

39-
- **Inside `/nginx/outside/main`**
56+
- **Inside `~/nginx/outside/main`**
4057
→ Files here are loaded **before Varnish**. Use this if you need to manipulate requests at the edge, before they hit the Varnish layer.
4158

4259
---
@@ -74,7 +91,7 @@ This ensures your new configuration is active without requiring a full restart.
7491
### Rewrites (`20rewrites.conf`)
7592

7693
1. **Custom Rewrite Rule (after Varnish)**
77-
Place in `/nginx/20rewrites.conf`:
94+
Place in `~/nginx/20rewrites.conf`:
7895

7996
```bash
8097
location /blog {
@@ -83,7 +100,7 @@ This ensures your new configuration is active without requiring a full restart.
83100
```
84101

85102
2. **Redirect Non-WWW to WWW**
86-
Place in `/nginx/20rewrites.conf`:
103+
Place in `~/nginx/20rewrites.conf`:
87104

88105
```bash
89106
if ($host ~ ^(?!www\.)(?<domain>.+)$) {
@@ -92,7 +109,7 @@ This ensures your new configuration is active without requiring a full restart.
92109
```
93110
94111
3. **Redirect WWW to non-WWW redirect**
95-
Place in `/nginx/20rewrites.conf`:
112+
Place in `~/nginx/20rewrites.conf`:
96113
97114
```bash
98115
if ($host ~* ^www\.(?<domain>.+)$) {
@@ -101,7 +118,7 @@ This ensures your new configuration is active without requiring a full restart.
101118
```
102119
103120
4. **Redirect to a Specific Page**
104-
Place in `/nginx/20rewrites.conf`:
121+
Place in `~/nginx/20rewrites.conf`:
105122
106123
```bash
107124
if ($http_host ~* "^.*your-domain\.be$") {
@@ -110,7 +127,7 @@ This ensures your new configuration is active without requiring a full restart.
110127
```
111128
112129
5. **Redirect Multiple Domains to Main Domain (keep URI)**
113-
Place in `/nginx/20rewrites.conf`:
130+
Place in `~/nginx/20rewrites.conf`:
114131
115132
```bash
116133
if ($http_host ~* "^(.*)(first-site\.be|second-site\.nl|third-site\.eu)$") {
@@ -122,7 +139,7 @@ This ensures your new configuration is active without requiring a full restart.
122139
123140
### Pre-Varnish Whitelisting (`outside/main/10whitelist.conf`)
124141
125-
Place in `/nginx/outside/main/10whitelist.conf`:
142+
Place in `~/nginx/outside/main/10whitelist.conf`:
126143
127144
```bash
128145
allow 192.168.0.0/24;

Technologies/Web Servers/NGINX/nginx_change_docroot.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ Some applications may require you to use a different docroot than the typical di
99
Note that this is mostly applicable for general applications. Many CMSes and frameworks have a custom docroot path, that we configure by default in nginx if you set up your application with the correct application type. Be sure to check your current settings before making any changes!
1010
!!!
1111

12+
For common CMSes and frameworks (Magento, shopware, ...etc) we recommend using the __application type__ to set the docroot, since setting it manually in `50main.conf` will cause TurboStack internals to not function correctly.
13+
14+
If your application is not found in the __application types__, please set the docroot manually in the `50main.conf` file.
15+
16+
1217
## 1. Using symlinks
1318

14-
The easiest way to make sure nginx reads application files in the correct directory, is simply by turning the default directory into a symlink, pointing to the desired directory. Consider the following default directory setup:
19+
The easiest way to make sure nginx reads application files in the correct directory, is simply by turning the default directory into a symlink, pointing to the desired directory. Consider the following default directory setup in `~/nginx/`:
1520

1621
```
1722
sander@web1:~$ ls -l

0 commit comments

Comments
 (0)