Browse Source

webserver stuff

tBKwtWS 6 years ago
parent
commit
5d3c043e1c
5 changed files with 82 additions and 6 deletions
  1. 10 5
      README.md
  2. 17 0
      uwsgi_params
  3. 2 1
      website/website/settings.py
  4. 32 0
      website_nginx.conf
  5. 21 0
      website_uwsgi.ini

+ 10 - 5
README.md

@@ -36,7 +36,7 @@ Fill in the passwords, don't change the database name, it's hardcoded in pyRot,
 1. `CREATE ROLE pyrot WITH LOGIN PASSWORD '';`
 1. `GRANT ALL ON DATABASE website TO pyrot;`
 
-## Settings file.
+## DB authentication
 
 For now, set the database authentication details in the following files:
 1. website/website/settings.py
@@ -48,6 +48,13 @@ For now, set the database authentication details in the following files:
 1. `python manage.py makemigrations`
 1. `python manage.py migrate`
 
+## Nginx configuration
+1. See if you to change `STATIC_ROOT` in `website/website/settings.py`.
+1. `ln -s /etc/nginx/sites-enables/`
+1. `sudo systemctl reload nginx`
+
+## uwsgi
+uwsgi command: `/opt/h0v1n8-env/bin/uwsgi --emperor /etc/uwsgi/vassals/ --daemonize /var/log/uwsgi-emperor.log`
 
 # Testing the project.
 
@@ -56,6 +63,7 @@ For now, set the database authentication details in the following files:
 1. `cd website`
 1. `python manage.py runserver`
 
+
 ## pyRot
 The pythonic version of RotBot, there have been 5 earlier versions including winRot and javaRot.
 
@@ -65,11 +73,8 @@ The pythonic version of RotBot, there have been 5 earlier versions including win
 
 # Edeting the look of the webgui
 
-## Build Fomatic-ui 2.7.8 
+## Build Fomatic-ui 2.7.8
 
 ### Requirements: NodeJS 10.15.3 & NPM 6.4.1
 
 On debian: `sudo apt install npm`
-
-
-

+ 17 - 0
uwsgi_params

@@ -0,0 +1,17 @@
+
+uwsgi_param  QUERY_STRING       $query_string;
+uwsgi_param  REQUEST_METHOD     $request_method;
+uwsgi_param  CONTENT_TYPE       $content_type;
+uwsgi_param  CONTENT_LENGTH     $content_length;
+
+uwsgi_param  REQUEST_URI        $request_uri;
+uwsgi_param  PATH_INFO          $document_uri;
+uwsgi_param  DOCUMENT_ROOT      $document_root;
+uwsgi_param  SERVER_PROTOCOL    $server_protocol;
+uwsgi_param  REQUEST_SCHEME     $scheme;
+uwsgi_param  HTTPS              $https if_not_empty;
+
+uwsgi_param  REMOTE_ADDR        $remote_addr;
+uwsgi_param  REMOTE_PORT        $remote_port;
+uwsgi_param  SERVER_PORT        $server_port;
+uwsgi_param SERVER_NAME         $server_name;

+ 2 - 1
website/website/settings.py

@@ -24,7 +24,7 @@ SECRET_KEY = 'f_nxx)y&fw6*u#dd_du6y9&)1$q+a0!y38+6sk151+6)@1kxge'
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = False
 
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ['*']
 
 
 # Application definition
@@ -131,6 +131,7 @@ USE_TZ = True
 # https://docs.djangoproject.com/en/2.2/howto/static-files/
 
 STATIC_URL = '/static/'
+STATIC_ROOT = '/srv/www/static/'
 STATICFILES_DIRS = [
     os.path.join(BASE_DIR, "semantic/dist"),
     os.path.join(BASE_DIR, "static"),

+ 32 - 0
website_nginx.conf

@@ -0,0 +1,32 @@
+# Upstream component nginx needs to connect to.
+upstream django {
+    server unix:///opt/h0v1n8-website-env/website/website/webgui.sock; # For production file socket
+    #server 127.0.0.1:8001; # Web port socket for use with uwsgi-hello-world-test.py
+}
+
+# Configuration of the server
+server {
+    # the port your site will be served on
+    listen      80;
+    # the domain name it will serve for
+    server_name _; # substitute your machine's IP address or FQDN
+    charset     utf-8;
+
+    # max upload size
+    client_max_body_size 75M;   # adjust to taste
+
+    # Django media
+    #location /media  {
+    #    alias /path/to/your/mysite/media;  # your Django project's media files - amend as required
+    #}
+
+    location /static {
+        alias /srv/www/static; # your Django project's static files - amend as required
+    }
+
+    # Finally, send all non-media requests to the Django server.
+    location / {
+        uwsgi_pass  django;
+        include     /opt/rotbot-env/uwsgi_params; # the uwsgi_params file you installed
+    }
+}

+ 21 - 0
website_uwsgi.ini

@@ -0,0 +1,21 @@
+[uwsgi]
+binary-path = /opt/h0v1n8-website-env/bin/uwsgi
+# Django-related settings
+# the base directory (full path)
+chdir           = /opt/h0v1n8-website-env/pyRot/webgui
+# Django's wsgi file
+module          = webgui.wsgi
+# the virtualenv (full path)
+home            = /opt/h0v1n8-website-env/
+
+# process-related settings
+# master
+master          = true
+# maximum number of worker processes
+processes       = 10
+# the socket (use the full path to be safe
+socket          = /opt/h0v1n8-env/website/website/webgui.sock
+# ... with appropriate permissions - may be needed
+chmod-socket    = 666
+# clear environment on exit
+vacuum          = true