Ceci est une ancienne révision du document !
So, after my proofreader had gotten through the last command and conquer paper, he said that he felt a little lost.
While that article was intended to be a high level overview and get you interested in having your own web server to play with, so you can create your own web pages, web games or whatever, I will now go over some web server-speak; I’ll focus on Nginx as it is by far the most popular. You may need it to make use of the Nginx documentation, as you, and I, as home users, do not “speak” that lingo.
The first thing you will run into will be directives and context. Directives are specific options that get set in the configuration file (not like the tree directives that robots have in Azimov’s tales). There is a name and its value. If you ever read up on programming, think of key-value pairs or dictionary entries. It is similar to an entry in a json file. So you will have something like -
domain: google.com,
distribution: ubuntu,
where “domain” is the name and “google.com” is the value, or “distribution” is the name and “Ubuntu” is the value.
Context is a whole section in the configuration that contains directives. The directives in the section set configurations for that context. Clear as mud, eh? Back to our coding example, context is like a block of code, you can have other blocks of code nested within that specific block of code that affects only the enclosing block of code. The same with context. You can have context nested within context, that contain directives specific to that context. Still muddy, eh? Ok, think of paragraphs in a book, except here, whatever happens in that paragraph pertains only to that paragraph. For instance you read how they dig a well in that paragraph, that happens only in that paragraph; if, further in the book, you read about someone digging a well, it has nothing to do with the well that was dug earlier. Though, overall in the story or chapter, there are two wells dug, each paragraph about digging wells knows only about their specific well. Within the context or “paragraph” if I put in -
distribution: Ubuntu, (directive)
then in another context “paragraph”: I can put in -
distribution: Mint,
it does not matter, as in that section we call the ‘context’, the key-value pair we call the ‘directive’, pertains only to that ‘context’.
If it still is not clear, please send a message to misc@fullcirclemagazine.com
The main configuration file is named the “main context”. Don’t ask, I did not name these things. The main context (aka config file) contains global directives (aka settings) - do I need to bring up local and global variables? You have been following our Python tutorial, haven’t you? Global directives apply to the master process.
As I said before, context can be nested, I will highlight a few important ones, so, within the main context, you will find, for instance, the ‘server context’ (where we defined our virtual host). We also have the ‘http context’, for http-related configurations and location context, to match requests incoming to the correct server context.
Navigate here: https://nginx.org/en/docs/http/ngx_http_core_module.html#http (see image on previous page)
Do you see where this jargon is used? This also tells us where you can find the directives you are looking for (~~hand wavy~~ These are not the ‘droids’ you are looking for!).
This is very important, it helps us not only read the documentation correctly, but it also helps us find where our directive should go (shown below).
If we look at the first example, we will find the context says it is in http, server and location, whereas merge_slashes is not found in “location”. Having it in a context where it does not belong, will mean it has no effect. If I have the above configuration in “location” context, it will not affect the “http” context even though they are both in the main context.
I hope this has cleared up some of the confusing bits in the series, so if I ever talk about context again while talking about web servers, I mean this ^^^, not some random context or in the context of the article. Have fun with your web servers!