Gupshup is an engagement tool used by us primarily to send whatsapp messages through their chatbot interface.
Functioning:
For an application seeking use Gupshup to establish a Whatsapp interface;
- The Application makes authenticated API Calls to Gupshup as elaborated in the Enterprise Guide .
- Gupshup interfaces with Whatsapp to send messages and recieve responses.
- Nginx recieves delivery reports, user messages, and other responses from Gupshup webhook.
- Nginx acts as a Reverse Proxy and sends relevant data to the application.
Reference: Nginx Beginners Guide
- Main Context: Global configuration settings, usually found in the
nginx.conf
file. - Events Context: Configures NGINX event-processing model, like worker connections.
- HTTP Context: Settings for HTTP/HTTPS, where you define
server
blocks (virtual hosts). - Server Context: Defines a virtual server to handle requests; you can have multiple
server
blocks. - Location Context: Specifies how to process requests for different resources within a
server
block.
proxy_pass
: Specifies the protocol and address of a proxied server and an optional URI.proxy_set_header
: Sets the value of a header field in the request sent to the proxied server.
Here's a simple example of configuring a reverse proxy in NGINX:
http {
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend_server_address:port;
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;
}
}
}
In this configuration, NGINX listens on port 80 and forwards all incoming HTTP requests to the specified backend server.
- Open/Create a Config File: Typically located at
/etc/nginx/nginx.conf
or/etc/nginx/sites-available/yourdomain
. - Set Up a Server Block: Start by defining a
server
block inside thehttp
context. - Specify Listening Port and Server Name: Use
listen
andserver_name
. - Configure Reverse Proxy: In a
location
block, useproxy_pass
to specify the backend server, andproxy_set_header
to handle headers. - Test Configuration: Validate your config with
nginx -t
. - Reload NGINX: Apply changes with
nginx -s reload
orsystemctl reload nginx
.
- Logging: Set up access and error logs for debugging.
- Securing the Proxy: Implement SSL/TLS for secure connections.
- Performance Tuning: Adjust worker processes and connections based on server capacity.
- Caching: Consider caching static content for improved performance.
- Use
nginx -t
to check the syntax before reloading. - Check NGINX error logs (
/var/log/nginx/error.log
) for issues.