Browse Source

Hopefully got some kinda ip forwarding support working again.

master
Trey Del Bonis 2 years ago
parent
commit
1097ef3b1a
2 changed files with 3 additions and 4 deletions
  1. 1
    3
      Dockerfile
  2. 2
    1
      app.py

+ 1
- 3
Dockerfile View File

@@ -4,7 +4,5 @@ COPY Pipfile Pipfile.lock docker-setup.sh /app/
RUN /app/docker-setup.sh
COPY . /app

EXPOSE 5000

WORKDIR /app
ENTRYPOINT ["uvicorn", "--proxy-headers", "app:app", "--host", "0.0.0.0", "--port", "5000"]
ENTRYPOINT ["uvicorn", "--proxy-headers", "--forwarded-allow-ips='*'", "app:app", "--uds", "/mnt/workdir/uvicorn.sock"]

+ 2
- 1
app.py View File

@@ -82,7 +82,8 @@ async def render_main(req: Request):

@app.post('/action/flag')
async def handle_flag(req: Request, date: str = Form(...), article: str = Form(...)):
ipaddr = req.client.host
xff = req.headers['X-Forwarded-For'] if 'X-Forwarded-For' in req.headers else None
ipaddr = xff if xff is not None else req.client.host

try:
today = datetime.now()

Loading…
Cancel
Save