From ab08de4f7b7c872444af54605091206d837031f6 Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Tue, 28 Apr 2020 12:10:14 +0200
Subject: [PATCH 1/8] add httpd conf

---
 src/fts3rest/httpd_fts.conf | 16 ++++++++++++++++
 src/runhttpd.sh             |  3 +++
 2 files changed, 19 insertions(+)
 create mode 100644 src/fts3rest/httpd_fts.conf
 create mode 100644 src/runhttpd.sh

diff --git a/src/fts3rest/httpd_fts.conf b/src/fts3rest/httpd_fts.conf
new file mode 100644
index 00000000..ebf9614b
--- /dev/null
+++ b/src/fts3rest/httpd_fts.conf
@@ -0,0 +1,16 @@
+<VirtualHost *:80>
+    <Directory /home/ftsflask/fts-rest-flask/src/fts3rest/>
+        Require all granted
+    </Directory>
+
+    WSGIScriptAlias / /home/ftsflask/fts-rest-flask/src/fts3rest/fts3restwsgi.py
+    # Note that it is highly recommended that the WSGI application script file in
+    # this case NOT be placed within the existing DocumentRoot for your main Apache
+    # installation, or the particular site you are setting it up for. This is
+    # because if that directory is otherwise being used as a source of static files,
+    # the source code for your application might be able to be downloaded.
+
+    WSGIDaemonProcess ftsrest processes=2 threads=15 python-home=/home/ftsflask/fts-rest-flask/venv
+    WSGIProcessGroup ftsrest
+    WSGIApplicationGroup %{GLOBAL}
+</VirtualHost>
diff --git a/src/runhttpd.sh b/src/runhttpd.sh
new file mode 100644
index 00000000..eae71636
--- /dev/null
+++ b/src/runhttpd.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+cp fts3rest/httpd_fts.conf /etc/httpd/conf.d
+systemctl restart httpd
-- 
GitLab


From d63824ebe79b8f866a4d07f843c11761e0593b6b Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Tue, 28 Apr 2020 12:22:56 +0200
Subject: [PATCH 2/8] add pythonpath

---
 src/runhttpd.sh => runhttpd.sh | 0
 src/fts3rest/httpd_fts.conf    | 1 +
 2 files changed, 1 insertion(+)
 rename src/runhttpd.sh => runhttpd.sh (100%)

diff --git a/src/runhttpd.sh b/runhttpd.sh
similarity index 100%
rename from src/runhttpd.sh
rename to runhttpd.sh
diff --git a/src/fts3rest/httpd_fts.conf b/src/fts3rest/httpd_fts.conf
index ebf9614b..5dca8a5f 100644
--- a/src/fts3rest/httpd_fts.conf
+++ b/src/fts3rest/httpd_fts.conf
@@ -10,6 +10,7 @@
     # because if that directory is otherwise being used as a source of static files,
     # the source code for your application might be able to be downloaded.
 
+    WSGIPythonPath /home/ftsflask/fts-rest-flask/src:/home/ftsflask/fts-rest-flask/src/fts3rest
     WSGIDaemonProcess ftsrest processes=2 threads=15 python-home=/home/ftsflask/fts-rest-flask/venv
     WSGIProcessGroup ftsrest
     WSGIApplicationGroup %{GLOBAL}
-- 
GitLab


From 68b76febd61725c6d92af5a72892f1ad803568e7 Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Tue, 28 Apr 2020 12:25:30 +0200
Subject: [PATCH 3/8] add pythonpath in venv

---
 src/fts3rest/httpd_fts.conf | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/fts3rest/httpd_fts.conf b/src/fts3rest/httpd_fts.conf
index 5dca8a5f..19711e0e 100644
--- a/src/fts3rest/httpd_fts.conf
+++ b/src/fts3rest/httpd_fts.conf
@@ -10,8 +10,10 @@
     # because if that directory is otherwise being used as a source of static files,
     # the source code for your application might be able to be downloaded.
 
-    WSGIPythonPath /home/ftsflask/fts-rest-flask/src:/home/ftsflask/fts-rest-flask/src/fts3rest
-    WSGIDaemonProcess ftsrest processes=2 threads=15 python-home=/home/ftsflask/fts-rest-flask/venv
+    WSGIDaemonProcess ftsrest processes=2 threads=15 \
+    python-home=/home/ftsflask/fts-rest-flask/venv \
+    python-path=/home/ftsflask/fts-rest-flask/src:/home/ftsflask/fts-rest-flask/src/fts3rest
+
     WSGIProcessGroup ftsrest
     WSGIApplicationGroup %{GLOBAL}
 </VirtualHost>
-- 
GitLab


From 2ee576203a33263b97d6ad888364f6a81ad251f1 Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Tue, 28 Apr 2020 12:37:10 +0200
Subject: [PATCH 4/8] add servername

---
 src/fts3rest/httpd_fts.conf | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/fts3rest/httpd_fts.conf b/src/fts3rest/httpd_fts.conf
index 19711e0e..59d1f40b 100644
--- a/src/fts3rest/httpd_fts.conf
+++ b/src/fts3rest/httpd_fts.conf
@@ -1,5 +1,9 @@
 <VirtualHost *:80>
-    <Directory /home/ftsflask/fts-rest-flask/src/fts3rest/>
+    LogLevel debug
+    ServerName localhost
+
+
+    <Directory /home/ftsflask/fts-rest-flask/src/fts3rest>
         Require all granted
     </Directory>
 
@@ -10,7 +14,7 @@
     # because if that directory is otherwise being used as a source of static files,
     # the source code for your application might be able to be downloaded.
 
-    WSGIDaemonProcess ftsrest processes=2 threads=15 \
+    WSGIDaemonProcess ftsrest processes=2 threads=15 user=ftsflask group=ftsflask \
     python-home=/home/ftsflask/fts-rest-flask/venv \
     python-path=/home/ftsflask/fts-rest-flask/src:/home/ftsflask/fts-rest-flask/src/fts3rest
 
-- 
GitLab


From e0fe40404e20f8e305b4c98051e28218785cc7fb Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Wed, 29 Apr 2020 09:42:57 +0200
Subject: [PATCH 5/8] default test config file

---
 README.md                    | 6 +++++-
 src/fts3rest/fts3restwsgi.py | 4 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index f93434ae..f6ec5cab 100644
--- a/README.md
+++ b/README.md
@@ -34,8 +34,12 @@ This project uses [pip-tools](https://github.com/jazzband/pip-tools) to manage d
 - `pipsyncdev.sh`: run it afterwards to synchronize the virtual environment with the requirements.
 
 # Installation requirements
-- yum install mod_wsgi python3-devel openssl-devel swig gcc gcc-c++ make httpd-devel mysql-devel
+Because we need mod_wsgi built for Python 3.6, we need to use httpd24-httpd
+selinux?
+- yum install python3-devel openssl-devel swig gcc gcc-c++ make httpd-devel mysql-devel
 - gfal2-python3
+- yum-config-manager --enable centos-sclo-rh
+- yum install  rh-python36-mod_wsgi
 # Installation requirements for development
 To create a development venv: use --system-packages in order to use gfal2-python3
 
diff --git a/src/fts3rest/fts3restwsgi.py b/src/fts3rest/fts3restwsgi.py
index 7ca78165..7ccb729f 100644
--- a/src/fts3rest/fts3restwsgi.py
+++ b/src/fts3rest/fts3restwsgi.py
@@ -1,5 +1,7 @@
 from fts3rest.config.middleware import create_app
 
 # default_config_filename = '/etc/fts3/fts3config'
-default_config_filename = "/home/ftsflask/fts-rest-flask/fts3config"
+default_config_filename = (
+    "/home/ftsflask/fts-rest-flask/src/fts3rest/fts3rest/tests/fts3config"
+)
 application = create_app(default_config_filename)
-- 
GitLab


From 7ad45a3dab6f12f9965abdaabe12237adebc705a Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Wed, 29 Apr 2020 09:46:30 +0200
Subject: [PATCH 6/8] fix

---
 src/fts3rest/fts3restwsgi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/fts3rest/fts3restwsgi.py b/src/fts3rest/fts3restwsgi.py
index 7ccb729f..e7932a05 100644
--- a/src/fts3rest/fts3restwsgi.py
+++ b/src/fts3rest/fts3restwsgi.py
@@ -2,6 +2,6 @@ from fts3rest.config.middleware import create_app
 
 # default_config_filename = '/etc/fts3/fts3config'
 default_config_filename = (
-    "/home/ftsflask/fts-rest-flask/src/fts3rest/fts3rest/tests/fts3config"
+    "/home/ftsflask/fts-rest-flask/src/fts3rest/fts3rest/tests/fts3testconfig"
 )
 application = create_app(default_config_filename)
-- 
GitLab


From 17c9877ae74e2fe5c80ce56fd65d8be5d935c36b Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Wed, 29 Apr 2020 10:48:32 +0200
Subject: [PATCH 7/8] use 8446

---
 README.md                   | 11 +++++++++--
 src/fts3rest/httpd_fts.conf |  3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index f6ec5cab..5fb327f9 100644
--- a/README.md
+++ b/README.md
@@ -35,15 +35,15 @@ This project uses [pip-tools](https://github.com/jazzband/pip-tools) to manage d
 
 # Installation requirements
 Because we need mod_wsgi built for Python 3.6, we need to use httpd24-httpd
-selinux?
 - yum install python3-devel openssl-devel swig gcc gcc-c++ make httpd-devel mysql-devel
 - gfal2-python3
 - yum-config-manager --enable centos-sclo-rh
-- yum install  rh-python36-mod_wsgi
+- yum install rh-python36-mod_wsgi
 # Installation requirements for development
 To create a development venv: use --system-packages in order to use gfal2-python3
 
 # How to run development server
+Flask:
 ```
 export PYTHONPATH=/home/ftsflask/fts-rest-flask/src:/home/ftsflask/fts-rest-flask/src/fts3rest 
 export FLASK_APP=/home/ftsflask/fts-rest-flask/src/fts3rest/fts3restwsgi.py
@@ -51,6 +51,13 @@ export FLASK_ENV=development
 flask run 
 curl  http://127.0.0.1:5000/hello
 ```
+httpd24:
+```
+cp httpd_fts.conf /opt/rh/httpd24/root/etc/httpd/conf.d/
+systemctl start httpd24-httpd.service
+curl http://localhost:80/hello
+```
+
 # Connect to local database
 ```
 
diff --git a/src/fts3rest/httpd_fts.conf b/src/fts3rest/httpd_fts.conf
index 59d1f40b..8a1ee50f 100644
--- a/src/fts3rest/httpd_fts.conf
+++ b/src/fts3rest/httpd_fts.conf
@@ -1,4 +1,5 @@
-<VirtualHost *:80>
+Listen 8446
+<VirtualHost *:8446>
     LogLevel debug
     ServerName localhost
 
-- 
GitLab


From b667719f6975b7f5d19f4474afa9b0bf7e180f5c Mon Sep 17 00:00:00 2001
From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch>
Date: Wed, 29 Apr 2020 14:29:18 +0200
Subject: [PATCH 8/8] Update readme

---
 README.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 5fb327f9..42ce0490 100644
--- a/README.md
+++ b/README.md
@@ -53,15 +53,18 @@ curl  http://127.0.0.1:5000/hello
 ```
 httpd24:
 ```
-cp httpd_fts.conf /opt/rh/httpd24/root/etc/httpd/conf.d/
+cp /home/ftsflask/fts-rest-flask/src/fts3rest/httpd_fts.conf /opt/rh/httpd24/root/etc/httpd/conf.d/
 systemctl start httpd24-httpd.service
 curl http://localhost:80/hello
 ```
 
 # Connect to local database
+To access the config page:
 ```
+INSERT INTO t_authz_dn VALUES ('yourdn');
 
 ```
+
 # Run tests 
 ```
 source venv/bin/activate
-- 
GitLab