WebAPI configuration after 3CX Update (NGINX)

Created by Anton Zykov, Modified on Mon, 31 Aug at 4:56 PM by Oleg Agapov

NGINX configuration for 3CX on Debian


1. Create the NGINX configuration snippet:

sudo nano /var/lib/3cxpbx/Bin/nginx/conf/snippets/webapi_debian.conf


2. Add the following configuration:

location ~ ^/webapi/?(.*)
{
    # allow 89.216.58.242;    # Uncomment to allow access only from a specific IP address
    # allow 89.216.58.0/24;    # Uncomment to allow access only from a specific IP subnet
    # deny all;               # Uncomment to allow access only from the specified IP addresses above
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8081/webapi/$1$is_args$args;
    proxy_buffering off;
    proxy_read_timeout 300;
    proxy_connect_timeout 300;
    proxy_send_timeout 300;
}

location /gui/
{
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8082/;
    proxy_buffering off;
}


3. Save the file (Ctrl+O, Enter) and exit (Ctrl+X).


4. Restart the 3CX NGINX web server:

systemctl restart nginx


One command

sudo wget -qO /var/lib/3cxpbx/Bin/nginx/conf/snippets/webapi_debian.conf https://download.creomate.com/v20/webapi_debian.conf && sudo nginx -t && sudo systemctl restart nginx


MS Windows


1. Create he NGINX configuration snippet: 

C:\Program Files\3CX Phone System\Bin\nginx\conf\snippets\webapi_win.conf


2. Add the following configuration:

location ~ ^/webapi/?(.*) 
{
  # allow 89.216.58.242;    # Uncomment to allow access only from a specific IP address
  # allow 89.216.58.0/24;    # Uncomment to allow access only from a specific IP subnet
  # deny all; # Uncomment to allow access only from the specified IP addresses above
  include "shared-headers.conf";
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass http://127.0.0.1:8081/webapi/$1$is_args$args;
  proxy_buffering off;
  proxy_read_timeout 300;
  proxy_connect_timeout 300;
  proxy_send_timeout 300;
}
location /gui/ {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8082/;
    proxy_buffering off;
}


3. Restart nginx Service (3CX Phone System Nginx Webserver)

sc stop nginx
sc start nginx



One command (Run PowerShell as Administrator)

$path="C:\Program Files\3CX Phone System\Bin\nginx\conf\snippets\webapi_win.conf"; New-Item -ItemType Directory -Force (Split-Path $path) | Out-Null; Invoke-WebRequest -Uri "https://download.creomate.com/v20/webapi_win.conf" -OutFile $path; Stop-Service nginx; Start-Service nginx

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article