I am trying to deploy a Flask app through nginx + Gunicorn. I am currently allowing my Flask app to be accessed by http://kramericaindustries.hopto.org:8050/ or http://kramericaindustries.hopto.org/heatmap/. However the later URL, with a URI of /heatmap/ presents a screen which just says "Loading..." indefinitely while the former loads correctly. I believe it has to do with my nginx.conf file, but I am new to nginx and not really sure what I'm doing wrong. I believe it has something to do with proxy directives but don't know. Below is my nginx.conf file, and the areas in question are near the bottom. Let me know if you have any questions or need any more information. Thanks!
user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name kramericaindustries.hopto.org; rewrite ^/rstudio$ $scheme://$http_host/rstudio/ permanent; location /rstudio/ { rewrite ^/rstudio/(.*)$ /$1 break; proxy_pass http://localhost:8787; proxy_redirect http://localhost:8787/ $scheme://$http_host/rstudio/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_read_timeout 20d; } location /heatmap/ { # rewrite ^/heatmap/(.*)$ /$1 break; proxy_pass http://127.0.0.1:8000; # proxy_redirect http://127.0.0.1:8000/ $scheme://$http_host/heatmap/; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 8050; server_name kramericaindustries.hopto.org; location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } } https://stackoverflow.com/questions/66718361/nginx-gunicorn-cannot-access-flask-app-without-root-location March 20, 2021 at 12:53PM
没有评论:
发表评论