Quick Navigation All projects Hardware Links Top projects Alan numitron clock Clapclap 2313/1386 SNES Pi Webserver USB Volume/USB toys Smokey amp Laser cutter WordClock ardReveil v3 SNES Arcade cabinet Game boy projects cameleon Home Presence Detector GitHub AlanFromJapan Contact me Who's Alan? Akizukidenshi Elec-lab Rand Nerd Tut EEVblog SpritesMods AvrFreaks Gameboy Dev FLOZz' blog Switch-science Sparkfun Suzusho Datasheet Lib Reddit Elec Ermicro Carnet du maker (fr) |
setup flask behind nginx proxyLast update: Sun Jul 28 14:14:33 2024
Because 1 server 2 apps is sometime what you want.
PresentationPrincipleTo do that, setup NginX in front of both sites on the same server as a reverse proxy. ImplementationStep 1 : NginxDo like RTFM 1 : https://flask.palletsprojects.com/en/2.2.x/deploying/nginx/EXCEPT that it's maybe better to : /etc/nginx/sites-available /etc/nginx/sites-enabled sudo nginx -t sudo service nginx restart Step 2 : FlaskSo though it works without telling Flask that it's behind a proxy, the makers of Flask say to do it so RTFM 2 : https://flask.palletsprojects.com/en/2.3.x/deploying/proxy_fix/ADDITIONALLY : link WITHOUT a leading / on the target URL or you'll end up at the root of your http://my-super-site.dot.com/ and not in the /aa "folder" (the proxy redirection to your site)One other option is to use flask URL processor to edit he URL dynamically : link. Step 3 : block direct access to appsMost likely you will not want to have your app accessible on http://my-super-site.dot.com:12345, so you need to block access from outside but not from the proxy.WORK IN PROGRESS! Not the answer alas: ufw deny in on eth0 to any port 12345 proto tcp LinksHelpful sources |
All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated) electrogeek.tokyo ~ Formerly known as Kalshagar.wikispaces.com and electrogeek.cc (AlanFromJapan [2009 - 2024]) |