Nginx: Difference between revisions
Jump to navigation
Jump to search
Add flask
imported>Sjwhitak (More links) |
imported>Sjwhitak (Add flask) |
||
To use a reverse proxy, remember the port your service is running on, and then add it into your nginx configuration:
<pre>
</pre>
This is a simple set up for an executable running on port 8080. I would ensure your firewall does not allow outside access to these ports, else anyone can directly access the service without nginx's protection.
Suppose you want multiple webapps, then:
<pre>
</pre>
If someone navigates to <code>example.com</code>, nginx serves them data from the service running on port <code>8080</code>.
This shows the purpose of the [https://nginx.org/en/docs/http/ngx_http_core_module.html#location <code>location</code>] directive.
=== flask ===
Running a simple flask server can be done in Python:
<pre>
from flask import Flask
app = Flask(__name__)
@app.route('/flask')
def main():
return "Flask app"
app.run(port=9999)
</pre>
And in nginx, the configuration should be:
<pre>
server {
location /flask {
proxy_pass http://localhost:9999;
}
}
</pre>
== <code>fastcgi</code> ==
|