Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx uwsgi supervisor #26

Open
tumregels opened this issue May 25, 2017 · 2 comments
Open

Nginx uwsgi supervisor #26

tumregels opened this issue May 25, 2017 · 2 comments

Comments

@tumregels
Copy link

tumregels commented May 25, 2017

Hi @DormyMo

First of all, thanks for the great tool.
The thing is that I tried to run SpiderKeeper using uwsgi and nginx but there is a small problem.
It loads correctly, but any click results in

404 Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

And there are no errors in the logs - therefore not posted here.

Here is the wsgi.py. I suppose the problem is here.

from SpiderKeeper import config
from SpiderKeeper.app import app, initialize


def create_app(config_object):
    initialize()
    return app


application = create_app(config_object=config)

Here is the uwsgi.ini

[uwsgi]
socket = :7000
master = true
processes = 4
threads = 8
enable-threads = true

plugin = python3
chdir = /srv/www/SpiderKeeper_webapp/SpiderKeeper
virtualenv = /srv/www/virtualenvs/SpiderKeeper
module = wsgi
callable = application

And nginx config file is the following.

# HTTP server to redirect all 80 traffic to SSL/HTTPS
server {
  listen 80;
  server_name spiderkeeper.somedomain.com;
  access_log  /srv/www/logs/nginx/SpiderKeeper-access.log;
  error_log   /srv/www/logs/nginx/SpiderKeeper-error.log info;

  # Tell all requests to port 80 to be 302 redirected to HTTPS
  return 302 https://$host$request_uri;
}

server {
  listen 443;
  ssl on;

  server_name spiderkeeper.somedomain.com;
  access_log  /srv/www/logs/nginx/SpiderKeeper-access.log;
  error_log   /srv/www/logs/nginx/SpiderKeeper-error.log info;

  location /static/  {
        alias /srv/www/SpiderKeeper_webapp/SpiderKeeper/SpiderKeeper/app/static/;   
  }

  ssl_certificate /etc/nginx/ssl/cert.crt;
  ssl_certificate_key /etc/nginx/ssl/cert.key;
  ssl_session_timeout 5m;
  ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  ssl_prefer_server_ciphers on;

  location / {
    try_files   $uri @yourapplication;
  }

  location @yourapplication {
    include     uwsgi_params;
    uwsgi_pass  127.0.0.1:7000;
  }
}

It would be great if you can help me with this issue. Thanks in advance

@tumregels
Copy link
Author

Looks like the problem is related to this issue

If an URL path element contains %2F (an escaped "/") Flask.route considers it as an unescaped slash

Any click results in a wrong url, e.g. https://spiderkeeper.somedomain.com/project//spider/dashboard

@tumregels
Copy link
Author

Ok, finally managed to solve it.

The setup for uwsgi.ini should be as follows

[uwsgi]
http = :7000
master = true
processes = 2
threads = 2
buffer-size=65535
limit-post = 5120000
post-buffering = 5120000
chdir = /srv/www/SpiderKeeper_webapp/SpiderKeeper
virtualenv = /srv/www/virtualenvs/SpiderKeeper
wsgi-file=wsgi.py

and nginx config is

# HTTP server to redirect all 80 traffic to SSL/HTTPS
server {
  listen 80;
  server_name spiderkeeper.somedomain.com;
  access_log  /srv/www/logs/nginx/SpiderKeeper-access.log;
  error_log   /srv/www/logs/nginx/SpiderKeeper-error.log info;

  # Tell all requests to port 80 to be 302 redirected to HTTPS
  return 302 https://$host$request_uri;
}

server {
  listen 443;
  ssl on;

  client_body_buffer_size     10M;
  client_max_body_size        10M;

  server_name spiderkeeper.somedomain.com;
  access_log  /srv/www/logs/nginx/SpiderKeeper-access.log;
  error_log   /srv/www/logs/nginx/SpiderKeeper-error.log info;

  location /static/  {
        alias /srv/www/SpiderKeeper_webapp/SpiderKeeper/SpiderKeeper/app/static/;   
  }

  ssl_certificate /etc/nginx/ssl/cert.crt;
  ssl_certificate_key /etc/nginx/ssl/cert.key;
  ssl_session_timeout 5m;
  ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  ssl_prefer_server_ciphers on;

  location / {
    proxy_pass   http:https://127.0.0.1:7000;
  }
}

wsgi.py is the same

from SpiderKeeper import config
from SpiderKeeper.app import app, initialize


def create_app(config_object):
    initialize()
    return app


application = create_app(config_object=config)

Zephyrrus pushed a commit to Zephyrrus/UBGuardian that referenced this issue Oct 25, 2020
…by_free_memory

Check for available memory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant