DirectAdmin Knowledge Base and Support

DirectAdmin is a web panel for a simple administration of both virtual and dedicated servers. DirectAdmin is faster, safe and more powerful than any other CP. And we know how to customize and support it.

I want Nginx to proxy request to my application

| 21:22:20 19.12.2022

Running Nginx + Apache on a Directadmin server, you can still configure Nginx to proxy requests to your Node.JS or Python application for your domain. And here is how can you do it.

All commands provided in the guide should be executed by "root" superuser in a server console (i.e. SSH).

Customize templates

Check the directory "/usr/local/directadmin/data/templates/custom/" whether it already contains the following files:

  • nginx_server.conf 
  • nginx_server_secure.conf

If it does not, then copy the mentioned files from "/usr/local/directadmin/data/templates/":

cd /usr/local/directadmin/data/templates/custom/
cp -p ../nginx_server.conf .
cp -p ../nginx_server_secure.conf .

Then open them in a text editor one by one and update.

nginx_server.conf

Add at the top of the file the following line:

|?PROXY_PASS=http://`PROXY_IP`:`PORT_8080`|

Save changes and exit.

nginx_server_secure.conf

Add at the top of the file the following line:

|?PROXY_PASS=https://`PROXY_IP`:`PORT_8081`|

Save changes and exit.

Update proxy_pass

Now run:

perl -pi -e "s#proxy_pass http.*:\/\/\|PROXY_IP\|:\|PORT_808.*\|;#proxy_pass \|PROXY_PASS\|;#" nginx_server.conf nginx_server_secure.conf

By completed this step we get a new custom token which can be changed on per domain bases in DirectAdmin Web-UI.

Customize token

Let's say we have an application on 127.0.0.1:2121 and want requests to example.net to be redirected to it. For it:

  • Connect to directadmin web interface as admin
  • Go to a "Custom HTTPD Configurations" page
  • Find your domain in a list on the page
  • Click "nginx proxy"
  • Add into a "Customization" section the following line (replace IP and port with your real values):
|?PROXY_PASS=http://127.0.0.1:2121/|

Save changes, wait a minute and have fun!

About Us
We are a team of professionals, and specialize in installation, configuring and managing of remote virtual and dedicated servers powered by Linux/Unix-like OS with DirectAdmin. We support various sets of software, including web-servers Apache, Nginx; internet domain name servers Bind, PowerDNS; mail-servers with POP3, IMAP and SMTP, FTP-servers, etc. After years of working through the most complex server challenges our team has gathered valuable experience and universal solutions suitable for everyday tasks. We are here to lend you a helping hand and take care of your servers in order to let you have enough time to do more of what you love.




All of the information and data on this site is for informational purposes only and is provided for the convenience of the user.
Powered by: Amiro.CMS - Free edition