Commit b975e41a authored by Romain Loth's avatar Romain Loth

update the doc for final nginx wrapping infos (TODO more)

parent e333c8c4
...@@ -13,9 +13,9 @@ More info in `doc/` directory ...@@ -13,9 +13,9 @@ More info in `doc/` directory
------- -------
### Setting up the servers ## Setting up the servers
#### Running it all via docker ### Running it all via docker
Prerequisites: Prerequisites:
- `docker` - `docker`
- `docker-compose` (>= v. 1.7.0) - `docker-compose` (>= v. 1.7.0)
...@@ -118,9 +118,10 @@ The form server is then accessible locally on `0.0.0.0:9090/regcomex` ...@@ -118,9 +118,10 @@ The form server is then accessible locally on `0.0.0.0:9090/regcomex`
------- -------
### Running in prod
#### Running in prod #### Nginx
TODO => we ask nginx to reverse-proxy our app We ask nginx to reverse-proxy our app
This is a minimal conf (cf [detailed doc](https://github.com/moma/regcomex/blob/master/doc/nginx_conf.md) for real-life conf) This is a minimal conf (cf [detailed doc](https://github.com/moma/regcomex/blob/master/doc/nginx_conf.md) for real-life conf)
...@@ -130,7 +131,7 @@ server { ...@@ -130,7 +131,7 @@ server {
listen 80; listen 80;
location /$ROUTE_PREFIX { location /$ROUTE_PREFIX {
proxy_pass http://127.0.0.1:9090; proxy_pass http://0.0.0.0:9090;
} }
} }
``` ```
...@@ -143,7 +144,7 @@ Currently the data is collected in `data/shared_mysql_data` ...@@ -143,7 +144,7 @@ Currently the data is collected in `data/shared_mysql_data`
The communityexplorer.org app is using a separate DB from legacy wiki csv The communityexplorer.org app is using a separate DB from legacy wiki csv
(cf [detailed doc](https://github.com/moma/regcomex/blob/master/doc/nginx_conf.md) for real-life conf) (cf [detailed doc](https://github.com/moma/regcomex/blob/master/doc/nginx_conf.md) for real-life conf)
**TODO:** connect the two **TODO:** connect the two DBs
------- -------
......
## Nginx configuration
Independantly from the backends like mysql or doors, the comex app is in two parts:
- the legacy php comex app
- the new python registration app
A good way to make the two coexist is to use nginx as follows
### 1) Install nginx ### 1) Install nginx
If you don't already have nginx on the deployment machine, follow these steps first:
``` ```
sudo service apache2 stop sudo service apache2 stop
sudo apt install nginx-full # contains uwsgi http module sudo apt install nginx-full
# check the status # check the status
systemctl status nginx.service # or sudo service nginx status sudo service nginx status
``` ```
### 2) Replace nginx conf by our *comex+reg* configuration
### 2) Add regcomex to nginx conf Create the conf files for comex
Create the conf files for regcomex
``` ```
cd /etc/nginx/sites-available cd /etc/nginx/sites-available
sudo nano regcomex.conf sudo nano comex.conf
``` ```
Exemple content to add in `/etc/nginx/sites-available/regcomex.conf` This below is a full config exemple you can paste in nano:
``` - it serves the comex app (legacy php), in `/`
- it also serves registration app, in `/regcomex`
```ini
# Full server config: php comex as root and regcomex as subpath
# =============================================================
server { server {
# your normal server conf here listen 80 ;
#listen 80; listen [::]:80 ;
#listen [::]:80;
#root /var/www ;
location /regcomex { server_name _;
proxy_pass http://127.0.0.1:9090; # gunicorn will be serving here
# adapt path to your php docroot
root /home/romain/comex/www ;
location / {
index index.html index.php ;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# here we adapted $documentroot to our real php docroot
fastcgi_param SCRIPT_FILENAME /home/romain/comex/www/$fastcgi_script_name;
# -----------------------
}
# no root here => independant app
# (but /locationpath must match this app's default route)
location /regcomex {
# point to gunicorn server
proxy_pass http://0.0.0.0:9090;
proxy_redirect off; proxy_redirect off;
# useful to keep track of original IP before reverse-proxy # useful to keep track of original IP before reverse-proxy
...@@ -40,8 +70,9 @@ server { ...@@ -40,8 +70,9 @@ server {
proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Forwarded-Host $server_name;
# get the logs in a custom place # get the logs in a custom place
access_log /home/romain/comex/regcomex/logs/nginx/access.log; # (adapt paths)
error_log /home/romain/comex/regcomex/logs/nginx/error.log; access_log /home/romain/comex/regcomex/logs/nginx/access.log ;
error_log /home/romain/comex/regcomex/logs/nginx/error.log debug;
} }
# faster static serving # faster static serving
...@@ -50,12 +81,18 @@ server { ...@@ -50,12 +81,18 @@ server {
autoindex on; autoindex on;
} }
location ~ /\.ht {
deny all;
}
} }
``` ```
Finally enable the conf Finally, to enable the conf:
``` ```
cd /etc/nginx/sites-enabled cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/regcomex.conf sudo ln -s ../sites-available/regcomex.conf
``` ```
**NB:**
If you use this configuration without changing anything else than the paths, then *remove* all other confs from `sites-enabled` (because this one is written to be standalone)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment