/ GETTING STARTED

How to build https with devspoon's web service

This page let you know how to set https service using 'Let's Encrypt' on devspoons web service.
We serve you shell script to make nginx conf file based on nginx server and it is already moved in docker container.
But to set the service, you have to access the container and do some process.
It's not difficult, if you will be following below manual.


Let's make PHP nginx server


* "let's encrypt" support many kind of authentication ways. In this page, we mention only webroot solution. It is required a web server applied domain address.

  1. Make php, nginx conf files for http service : "let's encrypt" will check try to access local folder to check server status.
    So, you have to make webroot folder under wwww folder and make php, nginx conf files too.
  2. Efficiently dockerfile configuration for development and service operation :The log folder is interlocked by "volumes" in docker-compose.yml so that user can can be tracked problems even when the docker container is stopped. Webroot, nginx config, etc. are frequently modified during development so these are interlocked by "volumes"
  3. Provide reverse proxy function :Multiple web and app services can be provided through one nginx with php or python and services can be provided simultaneously. A shell script is provided to easily create a proxy config file so that it can be integrated with the web UI of other services.
  4. Provides easy distributed service operation method :You can use multiple web servers through proxy, and you can use multiple app servers on one web server. (How to set load balancing will be supported in the future)

* This open source doesn't support database solution. To management DB data safely installing it at localhost is better.

So I recommend a reference link

Let's start the PHP server


This solution has www folder that synchronized with container by volumes in docker-compose.yml. And user can make webroot folder here like www/devspoons. Already therer is sample folder in www/sample. So user can refer at the folder of index file.

* If you want to use wordpress or gnuboard or any framework, after make any folder at www, move your ecompressed files here.


  1. Make webroot and copy files

    root# cd devspoon-web/www
    root# ls
    py37  sample
    
    root# mkdir devspoons-test
    root# cd devspoons-test
    root# echo -e "<?php\n\tphpinfo();\n?>" > index.php
    root# ls
    index.php

  2. Make nginx conf file

    • Docker-compose can connect between containers using application name in a docker-compose.yml file. Current PHP application name is php-app.
      If you don't have domain yet, can use ip address. but you can't use https setting on web service of ip address.
    root# cd devspoon-web/config/web-server/nginx/php
    root# ls
    conf.d  fastcgi  nginx_conf  nginx_conf.sh  nginx_https_conf.sh  sample_nginx.conf  sample_nginx_https.conf
    
    root# chmod 777 nginx_conf.sh
    root# ./nginx_conf.sh
    Enter the service web root >devspoons-test
    Entered service web root: devspoons-test
    Enter the service portnumber >80
    Entered service portnumber: 80
    Enter the service domain >devspoons.github.com
    Entered service domain: devspoons.github.com
    Enter the app name >php-app
    Entered app name: php-app
    Enter the serviceport
    if you push enter with none, there are no port number >9000
    Entered proxy port: 9000
    Enter the file name >devspoons-test1
    Entered file name: devspoons-test1
    
    root# cd conf.d/
    root# ls
    devspoons-test1_ng.conf  sample_php_ng.conf

  3. Make PHP conf file

    root# cd devspoon-web/config/app-server/php
    root# ls
    php_conf.sh  php_ini  pool.d  sample_php.conf
    
    root# chmod 777 php_conf.sh
    root# ./php_conf.sh
    Enter the service domain >devspoons.github.com
    Entered service domain: devspoons.github.com
    Enter the service portnumber >9000
    Entered service portnumber: 9000
    
    root# cd pool.d/
    root# ls
    devspoons.github.com_php.conf  sample_php.conf

  4. Run devspoon-web

    root# cd devspoon-web/compose/web_service/nginx_php
    root# ls
    docker-compose.yml
    
    root# docker-compose up -d

Let's start the Gunicorn server


This solution has www folder that synchronized with container by volumes in docker-compose.yml. And user can make webroot folder here like www/devspoons/. Already therer is sample folder in www/py37. So user can refer at the folder of index file.

* We assume that already user know how can make django project. So we will use sample django project named py37.


  1. Make webroot and copy files

    root# cd devspoon-web/www
    root# ls
    py37  sample

  2. Make nginx conf file

    • Docker-compose can connect between containers using application name in a docker-compose.yml file. Current gunicorn application name is gunicorn-app. if you want to change the name, update docker-compose.yml at devspoon-web/compose/web_service/nginx_gunicorn
      If you don't have domain yet, can use ip address. but you can't use https setting on web service of ip address.
    root# cd devspoon-web/config/web-server/nginx/gunicorn
    root# ls
    conf.d  nginx_conf  nginx_conf.sh  nginx_https_conf.sh  sample_nginx.conf  sample_nginx_https.conf
    
    root# chmod 777 nginx_conf.sh
    root# ./nginx_conf.sh
    Enter the service web root >/www/py37/django_test/repo
    Entered service web root: /www/py37/django_test/repo
    Enter the service portnumber >80
    Entered service portnumber: 80
    Enter the service domain >devspoons.github.com
    Entered service domain: devspoons.github.com
    Enter the app name >gunicorn-app
    Entered app name: gunicorn-app
    Enter the serviceport
    if you push enter with none, there are no port number >8000
    Entered proxy port: 8000
    Enter the file name >devspoons.github.com1
    Entered file name: devspoons.github.com1
    
    root# cd conf.d/
    root# ls
    devspoons.github.com1_gunicorn_ng.conf

  3. Update gunicorn executing script

    root# cd devspoon-web/docker/gunicorn
    root# ls
    Dockerfile  run.sh
    
    root# vim run.sh
    #!/bin/bash
    
    # update your djang project path
    cd /www/py37/django_test/repo  
    
    # update this line. workers = cpu core * 2
    #  --reload  = this option means if you update django code, gunicorn will restart the server itself
    gunicorn --workers 4 --bind 0.0.0.0:8000 conf.wsgi:application --daemon --reload 
    
    ...

  4. Run devspoon-web

    root# cd devspoon-web/compose/web_service/nginx_gunicorn
    root# ls
    docker-compose.yml
    
    root# docker-compose up -d

Let's start the UWSGI server


This solution has www folder that synchronized with container by volumes in docker-compose.yml. And user can make webroot folder here like www/devspoons/. Already therer is sample folder in www/py37. So user can refer at the folder of index file.

* We assume that already user know how can make django project. So we will use sample django project named py37.


  1. Make webroot and copy files

    root# cd devspoon-web/www
    root# ls
    py37  sample

  2. Make nginx conf file

    • Docker-compose can connect between containers using application name in a docker-compose.yml file. Current UWSGI application name is uwsgi-app. if you want to change the name, update docker-compose.yml at devspoon-web/compose/web_service/nginx_uwsgi
      If you don't have domain yet, can use ip address. but you can't use https setting on web service of ip address.
    root# cd devspoon-web/config/web-server/nginx/uwsgi
    root# ls
    conf.d  nginx_conf  nginx_conf.sh  nginx_https_conf.sh  sample_nginx.conf  sample_nginx_https.conf  uwsgi_params
    
    root# chmod 777 nginx_conf.sh
    root# ./nginx_conf.sh
    Enter the service web root >/www/py37/django_test/repo
    Entered service web root: /www/py37/django_test/repo
    Enter the service portnumber >80
    Entered service portnumber: 80
    Enter the service domain >devspoons.github.com
    Entered service domain: devspoons.github.com
    Enter the app name >uwsgi-app
    Entered app name: uwsgi-app
    Enter the serviceport
    if you push enter with none, there are no port number >8000
    Entered proxy port: 8000
    Enter the file name >devspoons.github.com1
    Entered file name: devspoons.github.com1
    
    root# cd conf.d/
    root# ls
    devspoons.github.com1_uwsgi_ng.conf

  3. Update UWSGI executing script

    • UWSGI has two of executing ways to run a server using python file and ini file.
      We serve both ways but explain only "ini" case in this manual.
      And uwsgi.ini support many arguments, So We don't mention it in this page.
    root# cd devspoon-web/config/app-server/uwsgi
    root# ls
    uwsgi.ini  uwsgi_config.py
    
    root# vim uwsgi.ini

  4. Run devspoon-web

    root# cd devspoon-web/compose/web_service/nginx_uwsgi
    root# ls
    docker-compose.yml
    
    root# docker-compose up -d

  • Trace log files

    • Check other log folders. If log option was setting, It will make a file at each folders.
      This manual explain only for nginx log case.
    root# cd devspoon-web/log/nginx
    root# ls
    devspoons.github.com.access.log devspoons.github.com.error.log

  • Upgrade Http to https

    Go to manual : How to build https with devspoon's web service