Skip to content

Pranab239/Transparent-SSL-Proxy-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Application with SSL and nginx Proxy

Overview

This project implements a Flask web application with SSL support and an nginx reverse proxy. The application allows users to submit messages which are stored in a JSON file and displayed on the home page. This project is divided into 6 tasks, where each task has its own functionalities as given in the project statement. The overview of the setup is given below:

Project Image

Features

  • Flask Web Application: Handles user messages and stores them in a JSON file.
  • SSL/TLS Encryption: Ensures secure communication.
  • nginx Reverse Proxy: Forwards requests to the Flask application.

Requirements

  • Python 3.x
  • Flask library
  • nginx reverse proxy

Installation

Python and Flask

  1. Clone the Repository

    git clone https://github.com/yourusername/your_flask_app.git
    cd your_flask_app
  2. Create and Activate a Virtual Environment

    python3 -m venv venv
    source venv/bin/activate
  3. Install Dependencies

    pip install -r requirements.txt

nginx

  1. Install nginx

    sudo apt-get update
    sudo apt-get install nginx
  2. Configure nginx

    Create a configuration file for your Flask app:

    sudo nano /etc/nginx/sites-available/your_flask_app

    Add the following content:

    server {
        listen 80;
        server_name yourdomain.com;
    
        location / {
            proxy_pass https://IP_ADRESS;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
  3. Enable the Site

    Create a symbolic link to enable the site:

    sudo ln -s /etc/nginx/sites-available/your_flask_app /etc/nginx/sites-enabled/
  4. Test nginx Configuration

    sudo nginx -t
  5. Restart nginx

    sudo systemctl restart nginx

Running the Flask Application

  1. Start the Flask App

    python app.py

    Ensure the Flask application is set to run with SSL:

    if __name__ == '__main__':
        app.run(host="0.0.0.0", port=5000, debug=True, ssl_context=('certB.pem', 'keyB.pem'))

    Create the certificates with the following command:

    openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

File Structure

This is a general file structure, generally file structure is varied upon different tasks.

your_flask_app/
│
├── app.py
├── user_data.json
├── requirements.txt
├── templates/
│   └── index.html
└── README.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published