User Tools

Site Tools


nginx

This is an old revision of the document!


Nginx Things

Reference Notes

Actually pretty decent reference Nginx Beginners Guide

location

Nginx reference, https://nginx.org/en/docs/http/ngx_http_core_module.html#location

location [ = | ~ | ~* | ^~ ] uri { ... }
location @name { ... }

=, ~, ~*, ^~ are all optional parameters

Without any of them, nginx will match request as prefix url, so it can be longer.
= Exact match, stops further searching
~ Regex, case sensitive
~* Regex, case insensitive
^~ Prefix match without following regex

Logic

Nginx divides it into prefix locations and regex locations. It starts going through prefix locations, selecting the longest that matches. With that selection, nginx runs through the regex matches. If = or ^~ is used, regex matching won't be done.

    location / {
        root /data/www;
    }

/ refers to the URI, so in this case the root URI
So the above returns files in /data/www

    location /images/ {
        root /data;
    }

Returns files in /data/images/

    location ~ \.(gif|jpg|png)$ {
        root /data/images;
    }

~ means the following is a regex. In this case, every address ending on gif, jpg, or png will return a file from /data/images

Examples

Basic Proxy Pass

server {
	listen 80;
	listen [::]:80;

	server_name cloud.lexrudera.net cloud.pulsewave.co;
	
	access_log /var/log/nginx/access-nextcloud80.log;
	error_log /var/log/nginx/error-nextcloud80.log;

	client_max_body_size 10G;
	fastcgi_buffers 64 4k;

	location / {
		proxy_pass http://192.168.0.102:8080;
	}
}

Basic UWSGI Pass

Like to a Gunicorn instance.

server
{
	listen 80;
	server_name radiotest.kirin.software;	
	
	location ~ {
		include uwsgi_params;
		uwsgi_pass unix:/var/run/uwsgi/radiotest.sock;
	}
}
nginx.1767830567.txt.gz · Last modified: by lex

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki