tiangolo / full-stack

Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
MIT License
523 stars 81 forks source link

Modify the existing nginx configuration, including an additional nginx module #20

Closed AYEG closed 5 years ago

AYEG commented 5 years ago

Hi! I'm looking to try out a different configuration for nginx to see if it can resolve a rpc connection problem and came across this section on custom nginx configurations https://github.com/tiangolo/uwsgi-nginx-flask-docker#customizing-nginx-configurations

According to the nginx docs I would need to use ngx_http_v2_module for this directive.

How can include that module in the nginx? Is there a way to include that at a later stage or should I actually rebuild the base image and import that into the backend.dockerfile.

I'm using the appropriate traefik grpc labels and traefik v1.7 with the latest grpc dependencies. I'm not sure if what I'm trying makes sense, background:

I'm trying to communicate to a Dgraph database from the backend container and after a period of inactivity the query from the client returns: "<_Rendezvous of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "OS Error" debug_error_string = "{"created":"@1546772849.163482552","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1036,"grpc_message":"OS Error","grpc_status":14}"

" After retrying the same query immediately it does work like it should, if possible, I'd like to prevent this connection error from happening all together. (Also tried changing host tcp settings to recommended values with no effect)

AYEG commented 5 years ago

It turns out I was reading outdated information, the http_v2_module has long been included in the stable release of Nginx. To see which modules can be configured in the current Nginx version:

docker exec -it bash nginx -V

AYEG commented 5 years ago

The easiest and probably best thing to do right now is to first try to add a *.conf file in nginx folder or edit the Nginx config in entrypoint.sh (https://github.com/tiangolo/uwsgi-nginx-docker/issues/36)

integrating the uwsgi-nginx-flask base images (and nginx.conf) into the project can be done as follows:

Finally change the FROM lines in uwsgi-nginx-flask.dockerfile and backend.dockerfile. Make sure the copy commands in the uwsgi_nginx.dockerfile and uwsgi_nginx_flask.dockerfile use the renamed uwsgi.ini files.

Now you can edit the files and work with a single supervisord.conf within /app, I noticed that a custom nginx.conf is not used. Changing the lines entrypoint.sh will get copied into the config , or adding a *.conf file in nginx folder.

tiangolo commented 5 years ago

Sorry for the delay @AYEG, I see you solved your problem. Nevertheless, I recently added a feature to allow overriding completely all the Nginx configuration, the new docs are here: https://github.com/tiangolo/uwsgi-nginx-flask-docker#overriding-nginx-configuration-completely

Also, on another note, I created https://github.com/tiangolo/fastapi, inspired by Flask, many of the plug-ins from this project generator and other tools.

If you are using this project generator with all the plug-ins, you would probably enjoy FastAPI a lot.

There is a also a comparable project generator to this one (but with more features): https://github.com/tiangolo/full-stack-fastapi-postgresql