You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Technologies/Web Servers/NGINX/nginx_basics.md
+26-9Lines changed: 26 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,30 @@ hidden: true
7
7
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:
8
8
9
9
```bash
10
-
/nginx
10
+
~/nginx/
11
11
```
12
12
13
13
This approach allows you to extend or override server behavior safely without interfering with the main system configs.
14
14
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
+
15
26
---
16
27
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
+
17
34
## Load Order of Config Files
18
35
19
36
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
33
50
34
51
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:
35
52
36
-
-**Inside `/nginx`**
53
+
-**Inside `~/nginx`**
37
54
→ Files here are loaded **after Varnish**. This is ideal for app-level rewrites, caching rules, or security headers.
38
55
39
-
-**Inside `/nginx/outside/main`**
56
+
-**Inside `~/nginx/outside/main`**
40
57
→ Files here are loaded **before Varnish**. Use this if you need to manipulate requests at the edge, before they hit the Varnish layer.
41
58
42
59
---
@@ -74,7 +91,7 @@ This ensures your new configuration is active without requiring a full restart.
74
91
### Rewrites (`20rewrites.conf`)
75
92
76
93
1.**Custom Rewrite Rule (after Varnish)**
77
-
Place in `/nginx/20rewrites.conf`:
94
+
Place in `~/nginx/20rewrites.conf`:
78
95
79
96
```bash
80
97
location /blog {
@@ -83,7 +100,7 @@ This ensures your new configuration is active without requiring a full restart.
83
100
```
84
101
85
102
2.**Redirect Non-WWW to WWW**
86
-
Place in `/nginx/20rewrites.conf`:
103
+
Place in `~/nginx/20rewrites.conf`:
87
104
88
105
```bash
89
106
if ($host~ ^(?!www\.)(?<domain>.+)$) {
@@ -92,7 +109,7 @@ This ensures your new configuration is active without requiring a full restart.
92
109
```
93
110
94
111
3. **Redirect WWW to non-WWW redirect**
95
-
Place in`/nginx/20rewrites.conf`:
112
+
Place in`~/nginx/20rewrites.conf`:
96
113
97
114
```bash
98
115
if ($host~* ^www\.(?<domain>.+)$) {
@@ -101,7 +118,7 @@ This ensures your new configuration is active without requiring a full restart.
101
118
```
102
119
103
120
4. **Redirect to a Specific Page**
104
-
Place in`/nginx/20rewrites.conf`:
121
+
Place in`~/nginx/20rewrites.conf`:
105
122
106
123
```bash
107
124
if ($http_host~*"^.*your-domain\.be$") {
@@ -110,7 +127,7 @@ This ensures your new configuration is active without requiring a full restart.
110
127
```
111
128
112
129
5. **Redirect Multiple Domains to Main Domain (keep URI)**
113
-
Place in`/nginx/20rewrites.conf`:
130
+
Place in`~/nginx/20rewrites.conf`:
114
131
115
132
```bash
116
133
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.
Copy file name to clipboardExpand all lines: Technologies/Web Servers/NGINX/nginx_change_docroot.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,14 @@ Some applications may require you to use a different docroot than the typical di
9
9
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!
10
10
!!!
11
11
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
+
12
17
## 1. Using symlinks
13
18
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/`:
0 commit comments