Stunnel + haproxy SSL and problem records

Source: Internet
Author: User
Tags install openssl rsync stunnel haproxy
Document directory
  • About SSL certificates
  • Others
  • Install haproxy by the way:
  • Some practical problems and solutions

Recently, Stunnel is used as a transparent proxy, and haproxy is used as an SSL solution. Stunnel is added between the user and the original reverse proxy, so that the user and Stunnel can use SSL, the real Web after Stunnel does not need to bear the HTTPS overhead.

Record the configuration process and problems. The following installation methods are successfully configured on centos and Ubuntu:

First, go to the Stunnel official website to obtain the installation package. Because we need to patch the Stunnel with haproxy, and the current version of the official patch provided by haproxy is 4.32, Stunnel is selected as version 4.32, you can find the FTP provided by the official website. Here, you can use the rsyncto synchronize the corresponding environment:

   1:  rsync stunnel-4.32.tar.gz
   2:  wget
   3:  tar -zxvf stunnel-4.32.tar.gz
   4:  cd stunnel-4.32
   5:  patch -p1 < ../stunnel-4.32-xforwarded-for.diff
   6:  ./configure
   7:  make && make install

If "couldn't find your SSL library installation dir" appears in the above process, OpenSSL is missing. After installation, perform the above process:

   1:  apt-get install libcurl3-openssl-dev


yum install openssl-devel

Configure Stunnel. conf:

   1:  sslVersion=all
   2:  fips=no
   3:  cert=/usr/local/etc/stunnel/stunnel.pem
   4:  CAfile=/usr/local/etc/stunnel/cacert.pem
   5:  pid =/var/run/
   6:  setuid=root
   7:  setgid=root
   9:  socket=l:TCP_NODELAY=1
  10:  socket=r:TCP_NODELAY=1
  11:  output=/var/log/stunnel.log
  13:  [https]
  14:  accept=443
  15:  connect=
  16:  TIMEOUTclose=0
  17:  xforwardedfor=yes


After completing the preceding steps, you can run:

   1:  stunnel

If the routines: fips_mode_set: fingerprint does not match error occurs when running stunel, you can set FIPS = No. If the nobody permission is displayed, you can set it:

   1:  chmod 755 /var/run/stunnel/


About SSL certificates

Use your own certificate:

   1:  openssl req -new -x509 -days 365 -nodes -out stunnel.pem -keyout stunnel.pem

If the existing certificate is imported into pfx and Ca (the corresponding cafile parameter is set in the configuration file ):

   1:  openssl
2: // convert CER to PEM
   3:  openssl>x509 -in cacert.cer -out cacert.pem
4: // pfx to PEM
   5:  openssl>pkcs12 -in stunnel.pfx -out stunnel.pem -nodes

To simplify the use of certificates, we will issue or purchase a certificate such as *, so that all sites under the second-level domain name can be shared. Note that *. * is invalid.



Stunnel can only be used as a proxy for Linux machines

You can differentiate IP addresses, IP addresses, and ports as proxies.

Simple and efficient, and a powerful system tool :)


Install haproxy by the way:

Find the version you want to install

Take centos5 installation as an example:

   1:  wget  
   2:  tar -zxvf haproxy-1.4.9.tar.gz
   3:  cd haproxy-1.4.9
   4:  make TARGET=linux26 PREFIX=/usr/local/
   5:  make install PREFIX=/usr/local/
Some practical problems and solutions

When using the SSL channel in IE6, the "page can not load" problem occurs. This is due to OpenSSL support issues. The official FAQ is as follows:

Http:// /? Page = FAQ


Stunnel is compatible, but no specific solution is attached. Here is the solution. Modify the Stunnel. conf configuration file:

   1:  ciphers=RC4-SHA

By the way, let's take a look at the encryption methods supported by IE6 (you can find them on the OpenSSL official website ):


Select an appropriate encryption algorithm. You can use log to check whether the algorithm is successfully loaded:

tail -f /var/log/stunnel.log

The ciphers settings are incorrect. Note that the sslversion in the configuration file will affect the matching of related algorithms.

Bytes -------------------------------------------------------------------------------------------------------

Because the client-to-stuunel is SSL, haproxy uses http to the Web, that is, the actual request URL is HTTP. In order to make the web end know whether the client-to-request URL is HTTP or HTTPS, you can use the following Configuration:

   1:  option forwardfor
   2:  option httpclose
   3:  reqadd X-Forwarded-Proto:\ https

On the web end, you can obtain the request header ["X-forwarded-Proto"] to distinguish

Please note that httpclose configuration: If this option is not available, X-forwarded is passed only for the first request. If this option is enabled, keepalive cannot be performed. If this option cannot be verified in windows

Bytes -------------------------------------------------------------------------------------------------------

The problem that HTTPS cannot be enabled due to the patch of IE in the XP system:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.