Guides
Domain Configuration
Route API and WebSocket traffic through production domains and TLS.
This page configures common domain entry points for OpenIMServer and ChatServer.
Prerequisites
- OpenIMServer and ChatServer are running successfully.
- Nginx is installed with the SSL module enabled.
- You have acquired a domain name and SSL certificate (for example,
im.yourhost.com). - TCP port
443is open on the server firewall.
On Debian or Ubuntu, install Nginx using apt-get install -y nginx.
Configure Nginx
Replace the domain name, certificate file paths, and backend upstream addresses in this configuration with your actual values:
upstream msg_gateway {
server 127.0.0.1:10001;
}
upstream im_api {
server 127.0.0.1:10002;
}
upstream im_chat_api {
server 127.0.0.1:10008;
}
upstream minio_s3 {
server 127.0.0.1:10005;
}
server {
listen 443 ssl;
server_name im.yourhost.com;
ssl_certificate /usr/local/nginx/conf/ssl/im.yourhost.com_bundle.pem;
ssl_certificate_key /usr/local/nginx/conf/ssl/im.yourhost.com.key;
location /msg_gateway {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://msg_gateway/;
}
location ^~ /api/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Request-Api $scheme://$host/api;
proxy_pass http://im_api/;
}
location ^~ /chat/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://im_chat_api/;
}
location ^~ /im-minio-api/ {
proxy_set_header Host $http_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_connect_timeout 300;
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio_s3/;
}
}Configure MinIO external address
- Source deployment: Modify
externalAddressinconfig/minio.yml. - Docker Compose deployment: Modify
MINIO_EXTERNAL_ADDRESSin.env.
Both deployment methods must be configured as:
https://im.yourhost.com/im-minio-apiValidate and reload Nginx
nginx -t
nginx -s reloadInitialize OpenIMClientSDK
apiAddr: https://im.yourhost.com/api
wsAddr: wss://im.yourhost.com/msg_gatewayGateway paths
| Path | Backend service |
|---|---|
/api/* | OpenIMServer API, port 10002 |
/msg_gateway | OpenIMServer WebSocket, port 10001 |
/chat/* | ChatServer API, port 10008 |
/im-minio-api/* | MinIO object storage, port 10005 |
This template does not proxy App Administrator APIs. If you need to route port 10009 through the domain entry point as well, configure a corresponding upstream and location block.