06. November 2022
Open source web and application server.
Project Homepage: Nginx Homepage Documentation: Nginx Unit Docs
Logging and debugging:
1error_log <file> <loglevel>
2 error_log logs/error.log;
3 error_log logs/debug.log debug;
4 error_log logs/error.log notice;
basic listening ports:
1listen <port> <options>
2 listen 80;
3 listen 443 ssl http2;
4 listen 443 http3 reuseport; (this is experimental!)
header modifcations:
1add_header <header> <values>
2 add_header Alt-svc '$http3=":<port>"; ma=<value>'; (this is experimental!)
3
4ssl_certificate / ssl_certificate_key
5 ssl_certificate cert.pem;
6 ssl_certificate_key cert.key;
7
8server_name <domains>
9 server_name domain1.com *.domain1.com
10
11root <folder>
12 root /var/www/html/domain1;
13
14index <file>
15 index index.php;
16
17location <url> {
18}
19 location / {
20 root index.html;
21 index index.html index.htm;
22 }
23 location / {
24 try_files $uri $uri/ /index.php$is_args$args;
25 }
26 location ~ \\.php$ {
27 fastcgi_pass 127.0.0.1:9000;
28 fastcgi_index index.php;
29 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
30 include fastcgi_params;
31 }
32 location ~ /\\.ht {
33 deny all;
34 }
35 location = /favicon.ico {
36 log_not_found off;
37 access_log off;
38 }
39 location = /robots.txt {
40 log_not_found off;
41 access_log off;
42 allow all;
43 }
44 location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
45 expires max;
46 log_not_found off;
47}
1server {
2 server_name example.com;
3 location / {
4 proxy_pass http://localhost:4000;
5
6 # Show clients real IP behind a proxy
7 proxy_set_header X-Real-IP $remote_addr;
8 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
9 }
10}