Even after running Nginx + Apache on the Directadmin server, you can configure Nginx to proxy requests for your Node.JS or Python applications to your domain. And here's how you can do it.
All commands given in the guide must be executed by the “root” superuser in the server console (i.e. ssh).
Customize template
Check the directory “/usr/local/directadmin/data/templates/custom/” to see if the following files are already present in it:
- nginx_server.conf
- nginx_server_secure.conf
If it doesn't, 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 one by one in a text editor and update.
nginx_server.conf
Add the following line at the top of the file:
|?PROXY_PASS=http://`PROXY_IP`:`PORT_8080`|
save Changes and exit.
nginx_server_secure.conf
Add the following line at the top of the file:
|?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
Completing this step gives us a new custom token that can be changed on a per domain basis in the DirectAdmin Web-UI.
customize token
Let's say we have an application 127.0.0.1:2121 Want more requests example.net To be redirected to. For this:
- Connect to the DirectAdmin web interface as administrator
- Go to the “Custom HTTPD Configuration” page
- Find your domain in a list on the page
- Click on “nginx proxy”
- Add the following line to the “Customization” section (replace IP and port with their actual values):
|?PROXY_PASS=http://127.0.0.1:2121/|
Save changes, wait a minute and enjoy!