KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Simple NGinx configuration for proxying to a 4D Server
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: February 15, 2018

Some deployments have required the use of a Reverse Proxy server in front of the 4D Web Server. Typically people have used Apache or IIS for this, but another alternative that could be used is NGinx (pronounced Engine-X).

NGinx is a simple and lightweight webserver that was developer for serving static pages. It also has a very good proxy engine for proxying requetss to other servers.

Here is a quick and simple configuration that can be used in NGinx to proxy the connection to 4D:

server {

listen 80; # listen on IPv4
listen [::]:80; # listen on IPv6

server_name example.com www.example.com;

access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;

root /var/www/html;

index index.html;

# proxy all requests to the 4D Server
location / {
proxy_pass https://your4Dserver:8081;
# this is the address that the 4D Web Server is at
}

# display a custom error when the 4D Server backend is down
error_page 502 @offline;
location @offline {
root /var/www/html;
try_files /502.html 502;
# this is the 502 error page displayed when the 4D server is down
# create the 502.html page at this location
# then customize it look as you like
}

# entry point for testing the 502 page without bring the 4D Server is down
location /testing {
fastcgi_pass unix:/does/not/exist;
# this allows you to test the 502 page
# using https://yourProxyServer/testing
}

}


This configuration is quick and simple to implement. This configuration is also easy to extend with a free certificate from Let's Encrypt, automated with certbot.

See Also: