i have a nginx service running with my server applications and the
configuration of my server applications public url is in it (something like https://api.mycompanyname.com.br).
i need to make a WebSocket that works with this public url.
My question is: its possible to use this url that is configurated on nginx service in a
TTMSFNCWebSocketServer component doing some especific configuration?
Sorry, we have no experience with NGINX.
We tested this here on Linux Ubuntu.
Ok, thank's for the answer.
I've found some nginx posts for doing it in a docker container,
i think it's the better way. When i make it work i'll post both configuration
here (nginx and WebSocket component)
After some days trying, i've finally made this work, here's the configutarions i used
nginx:
upstream backend {
server 127.0.0.1:8960;
}
server {
listen 443 ssl;
server_name api.mycompanyname.com.br;
ssl_certificate /path/to/ssl/certificate.crt;
ssl_certificate_key /path/to/ssl/private.key;
location / {
root html;
index index.html index.htm;
}
location /socket{
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://backend;
}
}
WEBSocket Server:
procedure TForm1.btnStartClick(Sender: TObject);
begin
FServer := TTMSFNCWebSocketServer.Create;
FServer.Port := 8960;
FServer.PathName := '';
FServer.CertificateFile := '';
FServer.CertificateKeyfile := '';
FServer.RootCertificateFile := '';
FServer.UseSSL := false;
FServer.OnMessageReceived := MessageReceived;
FServer.OnHandshakeResponseSent := HandshakeResponseSent;
FServer.OnGetSSLPassword := GetSSLPassword;
FServer.OnConnect := SocketServerConnect;
FServer.OnDisconnect := SocketServerDisconnect;
FServer.Active := True;
end;
And a plus, the client configuration:
procedure TForm1.btnConnectClick(Sender: TObject);
begin
TMSFNCWebsocketClient1 := TTMSFNCWebsocketClient.Create(nil);
TMSFNCWebsocketClient1.HostName := 'api.mycompanyname.com.br';
TMSFNCWebsocketClient1.Port := 443;
TMSFNCWebsocketClient1.UseSSL := True;
TMSFNCWebsocketClient1.PathName = '/socket';
TMSFNCWebsocketClient1.Active := true;
end;