Installing NGINX Server
NGINX Server for Linux
The following steps require root privilege, be sure that you have the correct access before continuing.
- Install an NGINX Server (Linux packages).
Run the following command to check the main NGINX configuration file:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
If the NGINX configuration file supports include directives, there will be a line like this:
include somedir/*.conf
- Create a configuration file
mft.conf
under this directory (normally/etc/nginx/conf.d
). This will create 2 locations: ‘/' for the UDMG Admin UI and'/service'
for the internal authentication mechanism.
upstream mft_auth_proxy {
# MFT Auth Proxy Configuration
server localhost:5000;
ip_hash;
keepalive 10;
}
server {
listen 8080;
server_name localhost;
access_log /var/log/nginx/host.access.log;
location /service/ {
proxy_pass http://mft_auth_proxy/;
}
location / {
try_files $uri $uri/ /index.html;
root /srv/www/mft;
}
}
- Validate that the configuration is correct with the following command:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
- Create the Root directory:
# mkdir -p /srv/www/mft
- Enable and start the NGINX service using the Init system.
# systemctl enable nginx
# systemctl start nginx
- Check that the HTTP server was started and is running, for example with the
curl
command:
# curl http://localhost:8080
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.21.6</center>
</body>
</html>
This error (403) is expected, since we don't have any asset deployed.
For configuring HTTPS and HTTP redirection, please refer to the web server documentation.
NGINX Server for Windows
The following steps require Administrator privileges, be sure that you have the correct access before to continue.
- Install NGINX (see nginx for Windows), for example under
C:\UDMG\nginx
.
Run the following command to check the main NGINX configuration file:
C:\UDMG\nginx> nginx -t
nginx: the configuration file C:\UDMG\nginx/conf/nginx.conf syntax is ok
nginx: configuration file C:\UDMG\nginx/conf/nginx.conf test is successfully
Create a directory under the configuration folder called "enabled" and add an include directive in the main configuration file inside the http section. For example:
http {
include mime.types;
default_type application/octet-stream;
include "C:/MFT/nginx/conf/enabled/*.conf";
- Create a configuration file
mft.conf
under this directory (normallyC:\UDMG\nginx\conf\enabled
):
upstream mft_auth_proxy {
# MFT Auth Proxy Configuration
server localhost:5000;
}
server {
listen 8080;
server_name localhost;
access_log logs//mft.access.log;
location /service/ {
proxy_pass http://mft_auth_proxy/;
}
location / {
try_files $uri $uri/ /index.html;
root mft;
}
}
- Validate that the configuration is correct with the following command:
C:\UDMG\nginx> nginx -t
nginx: the configuration file C:\UDMG\nginx/conf/nginx.conf syntax is ok
nginx: configuration file C:\UDMG\nginx/conf/nginx.conf test is successfully
- Create the Root directory under the NGINX main directory called mft:
C:\UDMG\nginx> mkdir mft
- Start NGINX
# start nginx
- Check that the HTTP server was started and is running, for example with the
curl
command:
C:\>curl.exe http://localhost:8080
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.23.0</center>
</body>
</html>
This error (403) is expected, since we don't have any asset deployed.
Notes:
- For configuring HTTPS and HTTP redirection, please refer to the web server documentation (Configuring HTTPS servers).
- Paths in an NGINX configuration file must be specified in UNIX-style using forward slashes '/'.