---
title: "Discussion on \"Use nginx as JWT authentication middleware\" | Hashnode"
description: "Discussion on \"Use nginx as JWT authentication middleware\". To have an authentication middleware inside Nginx itself has recently been an itch in my head. The idea is clean and straightforward. Read the request header and check the token, if it was verified let the request to proceed and otherwise block it. \n..."
url: "https://hashnode.com/posts/use-nginx-as-jwt-authentication-middleware/5d4da6b5fce164e52feebc4e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Use nginx as JWT authentication middleware](https://ehsanfa.hashnode.dev/use-nginx-as-jwt-authentication-middleware?utm_source=hashnode&utm_medium=feed)

To have an authentication middleware inside Nginx itself has recently been an itch in my head. The idea is clean and straightforward. Read the request header and check the token, if it was verified let the request to proceed and otherwise block it. ...

Aug 9, 2019 · ehsanfa.hashnode.dev  
Read the article

-   [#nginx](https://hashnode.com/tag/nginx)
-   [#lua](https://hashnode.com/tag/lua)
-   [#jwt](https://hashnode.com/tag/jwt)

## Written by

[Ehsan Fazeli](https://hashnode.com/@ehsanfa)

@ehsanfa · Darmstadt, Germany

  
[View profile](https://hashnode.com/@ehsanfa)

Software Engineer

## Responses 1

Markdown supported · ⌘↵ to post

[Fernando Gonzalez](https://hashnode.com/@campeon77)

[Nov 6, 2019](https://hashnode.com/posts/use-nginx-as-jwt-authentication-middleware/5d4da6b5fce164e52feebc4e/comment/5dc2d9c45f5f97c8348b5541)

what docker base image were you using for flask? (I am asking because ehsanfa/flask no longer exists in hub.docker.com)

Thanks

[Fernando Gonzalez](https://hashnode.com/@campeon77)

[Nov 6, 2019](https://hashnode.com/posts/use-nginx-as-jwt-authentication-middleware/5d4da6b5fce164e52feebc4e/comment/5dc2d9c45f5f97c8348b5541#reply-5dc2ddbb5f5f97c8348b5550)

Nevermind, this does the trick

FROM python:3.7.2-stretch

WORKDIR /app

RUN pip install flask uwsgi RUN pip freeze > requirements.txt

CMD export FLASK\_APP=index.py && flask run -h 0.0.0.0

[Ehsan Fazeli](https://hashnode.com/@ehsanfa)

[Nov 6, 2019](https://hashnode.com/posts/use-nginx-as-jwt-authentication-middleware/5d4da6b5fce164e52feebc4e/comment/5dc2d9c45f5f97c8348b5541#reply-5dc2e1c35f5f97c8348b55d3)

Hey [Fernando Gonzalez](https://hashnode.com/@campeon77), yeap you're right. It's just randomly disappeared. (Probably because of sanctions or smth)

I pushed it again to the docker hub, but it certainly was an ordinary image that did nothing but to run the flask and what you've written yourself does the job perfectly.
