How to configure Stunnel to connect to a service on HTTP[:3000] through HTTP[:80] and HTTPS[:443]

1.2k Views Asked by At

I have a PWA running on: 127.0.0.1:3000

With the following Stunnel config...

/etc/stunnel/stunnel.conf

client = no

[default]
accept = 443
cert = /etc/stunnel/example.com.pem
connect = 127.0.0.1:7777

[example.com]
sni = default:*example.com
cert = /etc/stunnel/example.com.pem
connect = 127.0.0.1:3000

... I'm able connect to that service by going to (through HTTPS):

But I also wants to connect to that service by going to (through HTTP):

Is there anyway to configure Stunnel to achieve that?

Thanks!

1

There are 1 best solutions below

0
Sergey Ponomarev On

No, the stunnel works only on a transport level and doesn't try to analyze packets. But this may be a good addition to it and shouldn't be that difficult. You may propose the change or pay to it's author to implement.

As a workaround you can start a small webserver like busybox httpd (already in Ubuntu) or Lighttpd or even just netcat and make a redirect with them. But this would be an additional software to start and configure. The current most popular solution is to use Nginx upfront as a reverse proxy. This is more complicated but gives more options.