Configure Nginx reverse proxy for V5 Exchange Provider
For additional support, visit our Support Center
After completing the V5 Exchange Provider setup steps above, you'll need to configure Nginx if your server uses it instead of Apache. This configuration provides reverse proxying, WebSocket support, compression, and various connection optimizations.
Use this configuration if you're running Nginx instead of Apache. This guide assumes you've completed the basic V5 setup process.
Click the Virtualmin tab in your hosting control panel.
Select the virtual server (domain) you want to configure.
Navigate to Services and then open Configure Nginx Website in a new tab.
Click Edit Nginx Directives.
In the editor, add the proxy and configuration lines after the existing location blocks or wherever appropriate.
If you prefer manual editing, SSH into your VPS and open the Nginx configuration file. The location varies based on your OS:
sudo nano /etc/nginx/sites-available/example.com.conf
sudo nano /etc/nginx/conf.d/example.com.conf
Replace example.com with your actual domain name.
Locate the server { ... } block for your domain. This block typically handles both HTTP and HTTPS traffic.
Add the following lines inside the server block after your root and index directives (adjusting paths and domain as needed):
Add this configuration inside your server block for V5 Exchange Provider:
# Essential proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_http_version 1.1;
# Buffer settings for large responses with [id] data
proxy_buffer_size 8k;
proxy_buffers 16 8k;
proxy_busy_buffers_size 16k;
# Enhanced timeouts for [id] parameter queries
keepalive_timeout 30s;
keepalive_requests 1000;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
# Header size limits for i18n locales (prevents 502 errors)
large_client_header_buffers 8 64k;
client_header_buffer_size 64k;
# Gzip compression (like DEFLATE)
gzip on;
gzip_types text/plain text/html text/xml text/css
application/xml application/xhtml+xml
application/rss+xml application/javascript
application/x-javascript application/json;
# Proxy to backend for /api/docs
location /api/docs {
proxy_pass http://localhost:4000/api/docs;
}
# Proxy to backend for /api with WebSocket upgrade
location /api {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:4000/api;
}
# Frontend proxy
location / {
proxy_pass http://localhost:3000/;
}
listen 443 ssl http2; and ssl_certificate directives properly setAfter editing, save the changes and exit the text editor. Run the following command to validate your Nginx configuration:
sudo nginx -t
If successful, you should see: nginx: configuration file /etc/nginx/nginx.conf test is successful
Once the configuration test passes, restart Nginx to apply the changes:
sudo systemctl restart nginx
You can also use sudo service nginx restart on older systems.
For WHM (Web Host Manager) users, follow these steps:
WHM provides a user-friendly interface for managing Nginx configurations without direct file editing.
nginx -tsudo nginx -s reload - Reload configurationsudo systemctl status nginx - Check service statussudo tail -f /var/log/nginx/error.log - View error logsnetstat -tlnp | grep :3000 - Check if app is runningIf you're still experiencing 502 errors after applying the nginx configuration, your application may have too many languages configured. Next.js generates alternate language headers for every page, and with many languages, these headers can exceed size limits.
NEXT_PUBLIC_LANGUAGES="en,es,fr,de,it,pt,ru,ar,ja,ko,hi,tr"
These 12 languages cover major global markets (~4.5B people) while keeping header sizes manageable.
frontend/next.config.jsNEXT_PUBLIC_LANGUAGES to essential languages onlynpm run buildpm2 restart frontendCongratulations! You've successfully updated the Nginx configuration. Your V5 Exchange Provider application should now serve requests via the configured reverse proxy, handle WebSockets, and apply performance optimizations.