Skip to content

Commit

Permalink
fix: FLASK_SERVER_NAME error behind reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed Jul 9, 2024
1 parent 11ac107 commit 20e8c77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEHIND_REVERSE_PROXY="false"
# set to "true" if your app is behind a proxy, this helps to get real IP address
# see: https://werkzeug.palletsprojects.com/en/latest/middleware/proxy_fix/#werkzeug.middleware.proxy_fix.ProxyFix
PROXYFIX_EXTRA_KWARGS='{}'
# e.g., {"x_prefix": 1} to make url_for work behind reverse proxy (like `URL Rewrite`)
# e.g., {"x_prefix": 1, "x_host": 1} to make url_for work behind reverse proxy (like `URL Rewrite`)
BIND_HOST="127.0.0.1"
BIND_PORT="5000"
SQLALCHEMY_DATABASE_URI="sqlite:///main.db"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Example rule:
<serverVariables>
<set name="HTTP_SEC_WEBSOCKET_EXTENSIONS" value="" />
<set name="HTTP_X_FORWARDED_PREFIX" value="/clip-basepath/" />
<set name="HTTP_X_FORWARDED_HOST" value="example.com" />
</serverVariables>
<action type="Rewrite" url="{C:1}://127.0.0.1:5000{R:1}" />
</rule>
Expand All @@ -130,7 +131,7 @@ Example rule:
#### URL Rewrite

- Download and install [URL Rewrite](https://www.iis.net/downloads/microsoft/url-rewrite)
- View Server Variables: add `HTTP_SEC_WEBSOCKET_EXTENSIONS` and `HTTP_X_FORWARDED_PREFIX` to allowlist
- View Server Variables: add `HTTP_SEC_WEBSOCKET_EXTENSIONS`, `HTTP_X_FORWARDED_PREFIX`, `HTTP_X_FORWARDED_HOST` to allowlist
- URL Rewrite Rules: see `web.config` below
- Virtual directory: point from `clip-basepath` to `server/app/templates`

Expand Down
1 change: 1 addition & 0 deletions server/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def parse_custom_args() -> None:

if any((export_metadata, export_openapi)):
no_run_server = True
environ["FLASK_ENV"] = "production"
from json import dump

if export_metadata:
Expand Down

0 comments on commit 20e8c77

Please sign in to comment.