Giter Site home page Giter Site logo

domain-routing-demo's Introduction

Domain Routing with Flask and Nginx

Prerequisites

  1. Install Docker: Make sure you have Docker installed on your machine. You can download it from the official Docker website.

  2. Run the Docker containers:

    docker-compose up
  3. Access the application:

    • Open your web browser and visit http://example.com and http://blog.example.com. Since this is a local setup, you'll need to update your local hosts file to map these domains to 127.0.0.1.

    • Add the following lines to your /etc/hosts file (Linux/macOS) or C:\Windows\System32\drivers\etc\hosts file (Windows):

      127.0.0.1 example.com
      127.0.0.1 blog.example.com
      
    • Now, try accessing http://example.com and http://blog.example.com again.

FAQs

  1. What is use of :ro in file compose.yaml?

In the Docker Compose configuration, the :ro at the end of the volume mount (/etc/nginx/nginx.conf:ro) stands for "read-only." This means that the file or directory from the host machine is mounted into the container in read-only mode. In the case of the Nginx container, the nginx.conf file is mounted into the container at the path /etc/nginx/nginx.conf, and it is marked as read-only (:ro). This ensures that the Nginx container can read the configuration but cannot modify it. It's a good practice to use read-only mounts for configuration files to enhance security and prevent accidental modifications within the container.

  1. What is use of proxy_set_header Host $host; in nginx.conf?

The proxy_set_header Host $host; directive in the nginx.conf file preserves the original Host header, ensuring accurate domain/subdomain information when forwarding requests to the Flask application.

Why?

domain-routing-demo's People

Contributors

nobleknightt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.