can serve dynamic websites only indirectly, because it is a web server for static content (HTML
, images, videos, compressed files, etc.), unlike Apache
, which uses plugins to take care of many scripting languages (PHP
and the like).
In combination with uWSGI
you are able to direct calls to dynamic content to something that handles those best: an application server. Meanwhile nginx
will keep on serving the remaining static content.
This form of encapsulation has some noticeable security advantages, as every webapp is handled by a separate instance of that application server (and not your web server, which is less likely to blow up in your face because of security flaws in the used scripting language), and that in turn is only accessible through your web server.
Obviously this also makes it possible to use nginx
as a load balancer
, as you can have one machine serve your domains and just redirect the traffic to other machines plainly serving the webapps.
I will keep to examples using a single machine (for brevity).
ships with /etc/nginx/uwsgi_params
holding a set of parameters for the application server, that are set to some of the web server's internally used variables.
uses a list of modifiers, that are explained in more detail in the list of packet descriptions
and of which some correspond to the usage of certain script languages.
When redirecting to a webapp nginx
in conjunction with the uwsgi_modifier1
stating the type of application: