nginx-ez.org 3.1 KB

Tweaking the configuration file

vocab

  • simple directive
  • =name parameter1 parameter2 parameter3:
  • block directive
  • A block directive has the syntax of a simple directive, but it surrounds text with two braces "{", "}". #+BEGIN_EXAMPLE name parameter1 parameter2 { # more programming type text goes here } #+END_EXAMPLE
  • context
  • A context is a block directive that has a block directive embedded in its braces.

#+BEGIN_EXAMPLE events { name parameter1 parameter2 {

} } #+END_EXAMPLE

Any directive not in a context is considered to be in the main context. The events and http context reside in the main context. While the server context is in http, and location is in server.

Nginx can have several server blocks with each block serving content from different websites. You can also serve different content if a client accesses your site from a specific port.

Events and http reside in the main content.

You can have 2 location blocks in one server context

Server is found in the http context, and location is always in a server context.

It's possible to have one server block get images from the var/image directory and serve html files from the /usr/share/nginx directory.

server { location / { root /usr/share/nginx; }

location images { root /var/image/; } }

check your changes for errors

If a URI matches several location blocks, then nginx will serve the one with the longest prefix. For example, GET images/pig.jpg matches both location blocks, BUT the second one has the longest prefix, so nginx serves the image from the second directory.


service nginx configtest  && service nginx restart

tutorials for using nginx to serve more than 1 domain name

https://linode.com/docs/web-servers/nginx/how-to-configure-nginx/

https://wiki.archlinux.org/index.php/Nginx#Configuration

https://wiki.archlinux.org/index.php/Network_configuration#Local_network_hostname_resolution

https://wiki.archlinux.org/index.php/Network_configuration#Set_the_hostname

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts

good online information for nginx

nginx and https

installing lemp in arch linux

optimizing nginx

https://serverfault.com/questions/654652/multiple-domains-name-on-one-server-with-nginx/772320 https://www.nginx.com/resources/wiki/start/ https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ https://wiki.debian.org/Nginx/DirectoryStructure To configure nginx for https, one should probably just use certbot.org. aka let's encrypt by Mozilla. However, nginx does need to be able to read the certificates. At the moment, it looks like it can, but also any process on my computer can read the certificate. I should probably tweak the permissions a bit... https://www.tecmint.com/install-nginx-php-mysql-with-mariadb-engine-and-phpmyadmin-in-arch-linux/ https://bjornjohansen.no/optimizing-https-nginx https://www.ssllabs.com/ssltest/analyze.html?d=www.gnusites.com https://weakdh.org/