Custom Content Providers
A Content Provider provides the actual web content (html pages) that nginx-le is to serve.
Nginx-le ship with a number of standard content providers:
  • static - serve static HTML content from a local directory.
  • generic - proxy a generic HTTP application server.
  • tomcat - proxy the tomcat web application server.
If none of the above methods suite your model then you can create your own custom content provider.
In most cases you can use the generic option. For example, if you have a PHP or a Ruby web server then simply use one of the standard nginx docker containers for PHP or Ruby and then use the nginx-le 'generic' Content Provider to have nginx-le proxy your docker container.
If you select any of the three built in Content Providers nginx-le automatically generates the location and upstream files required by nginx.
A custom Content Provider is simply one that provides its own location and upstream files for nginx.
Location file
By default Nginx-le:
  • configures Nginx to look for the location files (within the container) in: /etc/nginx/include/*.location.
  • mounts the host path /opt/nginx/include into the container path /etc/nginx/include.
When you select Custom Content Provider you need to provide your own location file in /opt/nginx/include.
location files must be named with a '.location' extension.
You can place any number of nginx location files in the /opt/nginx/include/host directory and all *.location files be mounted the next time that the Nginx-LE container is started or nginx is reloaded.
This is an example location file for proxying the java Tomcat server.
This location file requires an upstream file (see the example below) to be functional.
1
location / {
2
#try_files $uri $uri/ =404;
3
​
4
proxy_set_header Host $host;
5
proxy_set_header X-Real-IP $remote_addr;
6
proxy_set_header X-Forwarded-Proto https;
7
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
8
proxy_redirect off;
9
proxy_max_temp_file_size 0;
10
proxy_pass http://tomcat/mycontext/;
11
proxy_read_timeout 300;
12
}
13
​
14
location /mycontext {
15
#try_files $uri $uri/ =404;
16
​
17
proxy_set_header Host $host;
18
proxy_set_header X-Real-IP $remote_addr;
19
proxy_set_header X-Forwarded-Proto https;
20
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21
proxy_redirect off;
22
proxy_max_temp_file_size 0;
23
proxy_pass http://tomcat/mycontext/;
24
proxy_read_timeout 300;
25
}
Copied!
Upstream servers
If you Nginx-LE needs to proxy your web application server then you will need to provide one or more .upstream files to configure the connection to those servers.
upstream files must be named with a '.upstream' extension.
By default Nginx-LE:
  • mounts the host path /opt/nginx/include into the container path /etc/nginx/include.
  • configures Nginx to look for the upstream files (within the container) in: /etc/nginx/include/*.upstream.
When you select Custom Content Provider you need to provide your own upstream file in /opt/nginx/include.
Nginx-LE will load any /opt/nginx/include/*.upstream files from the host system.
You can place any number of nginx upstream files in this directory and they will be mounted the next time that the Nginx-LE container is started or nginx is reloaded.
This is an example upstream file for proxying the java Tomcat server
1
upstream tomcat {
2
server 127.0.0.1:8080 fail_timeout=0;
3
}
Copied!

​

Last modified 3mo ago
Copy link
Contents