Nginx: Difference between revisions

Jump to navigation Jump to search
497 bytes added ,  23 February 2022
More links
imported>Sjwhitak
(Bit of security)
imported>Sjwhitak
(More links)
 
In <code>/etc/nginx/nginx.conf</code>, <code>/etc/nginx/conf.d/*.conf</code> and <code>/etc/nginx/sites-enabled/*</code> are included. Therefore, if you have a complicated set up, you can split up your configuration among multiple files.
 
To test your configuration, <code>nginx -t</code> will tell you what syntax is wrong if there happens to be any. For instance, some directives can't be certain areas.
 
== A single domain ==
}
server {
root /var/www/wikimediamediawiki;
index index.html;
server_name wiki.example.com;
If someone navigates to <code>example.com/wiki</code>, nginx serves them data from the service running on port <code>8082</code>.
 
Why's there no [https://nginx.org/en/docs/http/ngx_http_core_module.html#root <code>root</code>] or [https://nginx.org/en/docs/http/ngx_http_index_module.html <code>index</code>]? It doesn't matter. nginx no longer bothers with any of that, since it's directly passing everything into the service.
 
This shows the purpose of the [https://nginx.org/en/docs/http/ngx_http_core_module.html#location <code>location</code>] directive.
The [https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param <code>fastcgi_param</code>] directive passes in information into the fastcgi server. The rest of the params are inside <code>/etc/nginx/fastcgi_params</code>, which is only 20 or so more params.
 
We only want to run <code>*.php</code> files into the fastcgi server, so we want to make sure only files that end with <code>.php</code> are actually passed into the fastcgi server (note the [https://nginx.org/en/docs/http/ngx_http_core_module.html#location <code>location</code>] directive).
= TLS =
[https://letsencrypt.org/ Let's Encrypt]'s certificates are valid for 3 months, so you can update this every 3 months when it expires. Or, have a cronjob do it for you! Type <code>crontab -e</code> and then add:
0 12 * * * /usr/bin/certbot renew --quiet
 
= Examples =
 
You want to run a blog that hosts static pages and a wiki that runs [https://www.mediawiki.org/wiki/MediaWiki mediawiki].
Anonymous user

Navigation menu