Changes for page Nginx: useful configuration directives
Last modified by Alexandru Pentilescu on 2023/06/25 18:58
From version 2.1
edited by Alexandru Pentilescu
on 2023/01/08 13:17
on 2023/01/08 13:17
Change comment:
There is no comment for this version
To version 3.2
edited by Alexandru Pentilescu
on 2023/01/08 13:24
on 2023/01/08 13:24
Change comment:
Added tag [technical guide]
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Tags
-
... ... @@ -1,0 +1,1 @@ 1 +technical guide - Content
-
... ... @@ -15,7 +15,7 @@ 15 15 16 16 = Mapping a specific URL location to a directory location on the system = 17 17 18 -Sometimes, you may want a very simple configuration where you have a specific URL location (i.e. **https://pentilescu.com/bin/**) and you want this URL prefix to indicate to Nginx to use a specific directory on the system to look for the requested files in. Or, in other words, every HTTP GET request sent to **https://pentilescu.com/bin/** (e.g. **https://pentilescu.com/bin/folder1/myfile.png**) to be searched for in a specific systems directory (e.g. **/var/www/static/**). This way, a request for **https://pentilescu.com/bin/folder1/myfile.png** should resolve to **/var/www/static/folder1/myfile.png**. How do we do this? 18 +Sometimes, you may want a very simple configuration where you have a specific URL location (i.e. **https://pentilescu.com/bin/ **) and you want this URL prefix to indicate to Nginx to use a specific directory on the system to look for the requested files in. Or, in other words, every HTTP GET request sent to **https://pentilescu.com/bin/ ** (e.g. **https://pentilescu.com/bin/folder1/myfile.png **) to be searched for in a specific systems directory (e.g. **/var/www/static/**). This way, a request for **https://pentilescu.com/bin/folder1/myfile.png ** should resolve to **/var/www/static/folder1/myfile.png**. How do we do this? 19 19 20 20 Simple! We use the "alias" directive, like so! 21 21 ... ... @@ -49,6 +49,35 @@ 49 49 Please note that the most important part of that snippet is the **location /bin/** directive, followed by the **alias**, which tells nginx to map all GET requests sent to the **/bin/** URL to the **/var/www/static** directory. 50 50 51 51 The other directories above it (i.e. the **location /robots.txt** directive) also use the **alias** directive, but they use it to map to a specific file location, rather than a directory location. This is also possible. 52 + 53 += Change maximum upload size that NGinx accepts = 54 + 55 +Sometimes, you may wish to upload files to your server. And sometimes, those files may be quite large in size. 56 + 57 +Nginx only allows uploads up to 1MB by default, which is very limited. 58 + 59 +At least for certain servers, you may wish to increase this limit to a higher cap. 60 + 61 +To do this, you must use the **client_max_body_size** directive, like so: 62 + 63 +{{code language="nginx"}} 64 +server { 65 + server_name wiki.pentilescu.com; 66 + 67 + listen [::]:443 ssl http2; # managed by Certbot 68 + listen 443 ssl http2; # managed by Certbot 69 + 70 + client_max_body_size 2500M; 71 + 72 + include /etc/nginx/snippets/ssl.conf; 73 + 74 + location / { 75 + proxy_pass http://localhost:8081; 76 + } 77 +} 78 +{{/code}} 79 + 80 +Here, we set the maximum upload file size to 2.5GB (i.e. 2500 MB). Any upload size greater than this will be rejected for the wiki.pentilescu.com domain. 52 52 ))) 53 53 54 54