Hi i am trying to create a python app and redis with nginx reverse-proxy but when i run the docker-compose file it runs all the container but when I go to localhost:90 it shows nginx page, not the page defined in python file. I was following this tutorial here
Docker file:
FROM python:3
RUN pip install flask
Python file:
from flask import Flask
app = Flask(__name__)
# to connect redis
# use host "redis_app"
# use port "6379"
# use password "add_password_here"
@app.route('/')
def hello():
return 'Hello NGINX reverse proxy'
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
Docker-compose-file
version: '3.1'
services:
nginx:
image: nginx:latest
container_name: nginx_reverseproxy
depends_on:
- flask
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- docker-network
ports:
- 90:80
flask:
build:
context: ./
dockerfile: Dockerfile
image: flask:v1
container_name: flask_webapp
volumes:
- ./:/flask_code/
environment:
- FLASK_APP=/flask_code/main.py
command: python /flask_code/main.py
networks:
docker-network:
aliases:
- flask_webapp
ports:
- 8080:5000
depends_on:
- redis
redis:
image: redis
networks:
docker-network:
nginx.conf
server {
listen 90;
server_name localhost;
location / {
proxy_pass http://flask_webapp:5000/;
proxy_set_header Host "localhost";
}
}
