Creating a local proxy server in python

I have two computers computer 1 and computer 2 on the same network. I’m trying to make computer 1 act as a proxy server so when I send a request from computer 2 using its ip address as a proxy, the request will pass through computer 1.
After trying multiple approaches, this is my code on the client side:

import requests

# Proxy server settings
PROXY_HOST = '192.168.1.112'
PROXY_PORT = 8888
url = 'https://www.google.com'
proxies = {
    'http': f'http://{PROXY_HOST}:{PROXY_PORT}',
    'https': f'http://{PROXY_HOST}:{PROXY_PORT}'
}

try:
    response = requests.get(url, proxies=proxies)
    print("Response from server:")
    print(response.content.decode('utf-8')) 
except requests.exceptions.RequestException as e:
    print(f"Error: {e}")

And this is the code on my server side (computer 1):

import socket
import threading
import ssl

LOCAL_HOST = '0.0.0.0'
PROXY_PORT = 8888

def handle_client(client_socket):
    request = client_socket.recv(4096)
    print(f"Received request from client: {request}")

    first_line = request.split(b'n')[0]
    method = first_line.split()[0]

    if method == b'CONNECT':
        handle_https(client_socket, request)
    else:
        handle_http(client_socket, request)

def handle_https(client_socket, request):
    # Extract the host and port from the CONNECT request
    first_line = request.split(b'n')[0]
    host, port = first_line.split()[1].split(b':')
    port = int(port)

    remote_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    remote_socket.connect((host.decode('utf-8'), port))

    client_socket.send(b'HTTP/1.1 200 OKnn')

    context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
    client_ssl = context.wrap_socket(client_socket, server_side=True)
    remote_ssl = context.wrap_socket(remote_socket, server_hostname=host.decode('utf-8'))


    forward_data(client_ssl, remote_ssl)

def handle_http(client_socket, request):
    remote_host = 'www.example.com'
    remote_port = 80

    remote_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    remote_socket.connect((remote_host, remote_port))
    remote_socket.send(request)

    remote_response = remote_socket.recv(4096)
    print(f"Received response from remote server: {remote_response}")

    client_socket.send(remote_response)

    remote_socket.close()
    client_socket.close()

def forward_data(sock1, sock2):
    sockets = [sock1, sock2]
    while True:
        for sock in sockets.copy():
            try:
                data = sock.recv(4096)
                if data:
                    other_sock = sock2 if sock == sock1 else sock1
                    other_sock.sendall(data)
                else:
                    sock.close()
                    sockets.remove(sock)
            except Exception as e:
                print(f"Error: {e}")
                sock.close()
                sockets.remove(sock)

def start_proxy_server():
    proxy_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    proxy_socket.bind((LOCAL_HOST, PROXY_PORT))
    proxy_socket.listen(5)
    print(f"Proxy server listening on port {PROXY_PORT}...")

    while True:
        client_socket, addr = proxy_socket.accept()
        print(f"Accepted connection from {addr[0]}:{addr[1]}")

        # Handle client request in a separate thread
        client_handler = threading.Thread(target=handle_client, args=(client_socket,))
        client_handler.start()

if __name__ == '__main__':
    start_proxy_server()

If I send an http request that works well, but when sending an https request I’m getting this error on the server side during the handshake proccess:
ssl.SSLError: [SSL: NO_SHARED_CIPHER] no shared cipher (_ssl.c:1000)

I tried to add this to my code but it didn’t help:

cipher = 'DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-GCM-SHA256'
context.set_ciphers(cipher)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật