10-12-2020 11:24 PM
I setup a web service and host the both HTTP and HTTPS service.
Is it possible to redirect all the income HTTP traffic to HTTPS?
example:
1) On browser user type http://hostname/webservice/index.html
2) server redirect it to https://hostname/webservice/index.html
Best regards,
Khoh
Solved! Go to Solution.
10-13-2020 02:56 AM
AFAIK, HTTPS is HTTP over SSL.
I think in recent versions you can get LabVIEW to do that for you, but I haven't tried it recently.
In the past, I used stunnel for that.
10-13-2020 04:29 AM
a bit confuse on using stunnel, can you hint the setup step? I'm using window OS.
Best regards,
Khoh
10-13-2020 05:00 AM - edited 10-13-2020 05:01 AM
I can post what I've used, but I'm no expert, and it's been a few years since I last used it.
I can validate that setting it up wasn't trivial, but once it was setup, it worked like a charm.
I hope you've found the howto? I bookmarked that in my project, it's been a great help.
In the stunnel.conf below I bolded the things that I changed. IIRC, the incoming HTTPS on port 8080 is automatically routed. This could require a certificate (it did for me) and that was the hard part. Certificates are hard. IIRC, I created my own, using OpenSSL (sslcerts.html). You might not need it for all HTTPS connections, or you might need a specific certificate. I think it's application specific.
I think I left everything that comes with stunnel untouched, except the stunnel.conf. Even that file was mostly unchanged, except the bolded parts. I'm not sure about the https2:
; Certificate/key is needed in server mode and optional in client mode
; The default certificate is provided only for testing and should not
; be used in a production environment
cert = certificate\\myapp.pem
key = certificate\\myapp-insecure.key
; Some performance tunings
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
; Authentication stuff;
verify = 0
; Don't forget to c_rehash CApath
;CApath = certs
; It's often easier to use CAfile
;CAfile = cnes_certificate.pem
; Don't forget to c_rehash CRLpath
;CRLpath = crls
; Alternatively you can use CRLfile
;CRLfile = certificate.pem
; Some debugging stuff useful for troubleshooting
debug = 7
;output = stunnel.log
; Use it for client mode
;client = yes
; Service-level configuration
[https]
connect = localhost:80
accept = localhost:8080
;TIMEOUTclose = 0
[https 2]
accept = 443
connect = 80