Skip to content

Python HTTPS proxy server with HTTP basic authentication

Notifications You must be signed in to change notification settings

mironovdm/tls-basic-auth-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

This is a simple Python HTTPS proxy server with HTTP basic authentication. It is intended to use when you need to secure an access to some plain HTTP resource and you don't want to mess with installing and configuring special software like Nginx and etc.

Uses threads to handle connections so not suitable for high loads.

Important note: keep-alive connections are not supported yet.

Setup

Just copy source files to preferred directory.

Configuration

Open settings.py file. Set these variables to the values that determine the server that you want to secure:

PROXIED_HOST = 'localhost'
PROXIED_PORT = 9090

These settings determine network interface where this TLS-server will listen for incoming connections. Leave HOST to empty string if you need to listen on all available interfaces:

HOST = ''
PORT = 9091

Change basic-auth credentials to preferred values:

BASIC_LOGIN = 'admin'
BASIC_PASSWD = 'passwd'

The last step is to set the CERTFILE_PATH and KEYFILE_PATH to values that define where your SSL certificate and private key files are located.

If you don't have an SSL certificate signed with trusted certificate authority you can refer to Let's Encrypt project to issue free trusted certificate or just use self-signed certificate. Note that in the latter case a browser will alert you about untrusted certificate.

To create and use self-signed certificate type this command in the terminal in the directory where you placed this script:

mkdir ssl
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout ssl/private.pem -out ssl/cert.pem

and leave default values for CERTFILE_PATH and KEYFILE_PATH.

Running

In the project directory type the command in terminal:

python3 server.py

On Linux if you need the server to run in the background then type the command:

nohup python3 server.py &

About

Python HTTPS proxy server with HTTP basic authentication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages