Swi prolog https server

dear forum,
I am trying to activate a swi prolog https server on a windows server machine, running next to apache which itself runs on port 443.

I made some .pl server scripts so that swi prolog can serve data from certain files. I tested that on localhost on another machine, that works.

Now on the internet- server i let the server start with : ( I use port 8443 )
server(Port) :-
http_server(http_dispatch, [port(Port), ssl([ certificate_file(‘C:\xampp\apache\conf\ssl.crt\server.crt’), key_file(‘C:\xampp\apache\conf\ssl.key\server.key’) ]) ]).

swi runs this without complaints. Then the server is answering the way it should when i call for example
http://localhost:8443/?queryfieldname=datastr

then after that I would like to get https html files (from apache ) in combination with swi server data ( from : 8443 ) with a web-browser ( for example firefox )

then I call the https page first which succeeds,
Then i want to call the swi ssl server from within that page through javascript xml-request
, the firefox complains When i call the the swi data server through http://www.domain.com:8443
Because it thinks that https with http-call afterwards (swi server call ) is not allowed because unsafe.
therefore I should call the swi-server as : https://www.domain.com:8443

but with that the swi-server doesnt answer. I have allowed the firewall for 8443 and that seems to work also with normal http://www.domain.com:8443 call.

Is it possible to get the swi server working next to apache with both on ssl?

basically the call : https://www.domain.com:8443/?query=datastr
is double because 8443 is already considered as ssl connection, but is it that firefox wants it that way?

or can this only be working when swi runs solely on https 443 without any other servers?

I use apache mainly for serving the files, and swi server for serving other data, that would be a great combination

Any answers would of course be appreciated. I prepared the swi-data server completely locally, but it seems I cant get it running the right way through ssl next to the apache server.

I let swi call the same 2 certificate files as which are be used by apache.

Well, you get answers from http:// rather than https://, so it appears to be that HTTPS is not enabled. To get HTTPS, you must load (in addition to the normal HTTP stuff)

:- use_module(library(ssl)).
:- use_module(library(http/http_ssl_plugin)).

Next we have C:\xampp\apache\conf\ssl.crt\server.crt, which doesn’t work. Use / instead of \ as the backslash is an escape character. You can also use \\, but SWI-Prolog’s file name handling expects / and will change that to \ just before calling the Win32 API functions where needed. Normally you’d get s syntax error, but in this unfortunate case all the escape sequences are defined and thus you get a quite different file name :frowning:

?- write('C:\xampp\apache\conf\ssl.crt\server.crt').
C:
mpppacheonf sl.crt erver.crt
true.

Because \xa is the character 10, \a is alarm (7), \c eats white space and ‘\s’ is a space :slight_smile:

No. https:// specifies the protocol (TLS). This implies port 443, which you can overrule using the :8443 extension. http:// specifies plain text protocol which implies port 80.

This can work. In most cases I’d let SWI-Prolog also serve the files though. It is a simple one liner using serve_files_in_directory/2 and you can put the Prolog server on port 443 and be done. That should simplify deployment considerably.

dear Jan, thankyou a lot for the extensive information! I am going to try to make it work with this information.

swi-prolog is a great tool, and it has a lot of capabilities