Skip to content

Build your personal knowledge base with Trilium Notes

configurable port plus support for SSL

azivner3c924afbca69
diff --git a/.gitignore b/.gitignore
index 837cfc101c..e9f8402672 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,6 @@ npm-debug.log
yarn-error.log
app.pyc
demo.ncdb
-config.ini
\ No newline at end of file
+config.ini
+cert.key
+cert.crt
\ No newline at end of file
diff --git a/config-sample.ini b/config-sample.ini
index 5648cafe61..bf2c544c5d 100644
--- a/config-sample.ini
+++ b/config-sample.ini
@@ -1,8 +1,13 @@
+[Network]
+port=5000
+certPath=cert.crt
+certKeyPath=cert.key
+
[Login]
# Enter below credentials with with which you want to authenticate to Notecase web app
-username=adam
+username=your_username
# This is bcrypt password hash. You can use generate-password.py (in this directory) to hash your password
-password-hash=$2b$12$4Ia5lYbbpOv3pxxdoDgjUeAJ9z4FhqyEhhX52ra78FH03wPGx8zGu
+password-hash=$2b$12$FHT8keXp3BGTfzAV/VnrkuLpkwN8Vpj5iIh4RwCbHTNWYSBI9hGAK
[Sync]
sync-server-url=https://localhost:57201
diff --git a/generate-cert.sh b/generate-cert.sh
new file mode 100644
index 0000000000..770357edc3
--- /dev/null
+++ b/generate-cert.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+openssl genrsa -des3 -out cert.key 2048
+
+openssl req -new -key cert.key -out cert.csr
+
+# Remove passphrase from key
+cp cert.key cert.key.org
+
+openssl rsa -in cert.key.org -out cert.key
+
+# Generate self signed certificate
+openssl x509 -req -days 730 -in cert.csr -signkey cert.key -out cert.crt
+
+rm cert.key.org
+rm cert.csr
\ No newline at end of file
diff --git a/run-debug.sh b/run-debug.sh
new file mode 100644
index 0000000000..1cf658d8e9
--- /dev/null
+++ b/run-debug.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export FLASK_DEBUG=0
+export FLASK_APP=src/app.py
+
+flask run
\ No newline at end of file
diff --git a/run.sh b/run.sh
index 7a6afb26bf..1cf658d8e9 100644
--- a/run.sh
+++ b/run.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-export FLASK_DEBUG=1
+export FLASK_DEBUG=0
export FLASK_APP=src/app.py
flask run
\ No newline at end of file
diff --git a/src/app.py b/src/app.py
index a43ea78f52..f2c7e81f3b 100644
--- a/src/app.py
+++ b/src/app.py
@@ -42,6 +42,10 @@ config.read('config.ini')
user = User()
user.id = config['Login']['username']
+port = config['Network']['port']
+certPath = config['Network']['certPath']
+certKeyPath = config['Network']['certKeyPath']
+
hashedPassword = config['Login']['password-hash'].encode('utf-8')
@app.route('/login', methods=['POST'])
@@ -85,5 +89,5 @@ def load_user(user_id):
api.add_resource(Notes, '/notes/<string:note_id>')
-if __name__ == '__main__':
- app.run(host='0.0.0.0')
\ No newline at end of file
+if __name__ == "__main__":
+ app.run(host='0.0.0.0', port=port, ssl_context = (certPath, certKeyPath))
\ No newline at end of file
diff --git a/src/templates/login.html b/src/templates/login.html
index 724eab9d7f..f5c8c8ab1d 100644
--- a/src/templates/login.html
+++ b/src/templates/login.html
@@ -44,7 +44,7 @@
</div>
</div>
- <link href="static/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
- <script src="static/lib/bootstrap/js/bootstrap.js"></script>
+ <link href="stat/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
+ <script src="stat/lib/bootstrap/js/bootstrap.js"></script>
</body>
</html>
\ No newline at end of file