From 9e1541e7b62d8f9b289adc5c45f43cb0146c29dc Mon Sep 17 00:00:00 2001 From: Leon Morten Richter Date: Thu, 30 Jun 2022 15:04:23 +0200 Subject: [PATCH] simplify setup --- README.md | 26 ++++++++++++++++++-------- docker-compose.yml | 9 +++------ nginx/nginx-selfsigned.crt | 0 nginx/nginx-selfsigned.key | 0 nginx/nginx.conf | 3 +-- nginx/nginx.conf.https | 22 ---------------------- 6 files changed, 22 insertions(+), 38 deletions(-) create mode 100644 nginx/nginx-selfsigned.crt create mode 100644 nginx/nginx-selfsigned.key delete mode 100644 nginx/nginx.conf.https diff --git a/README.md b/README.md index 2a70bf0..f997ed3 100644 --- a/README.md +++ b/README.md @@ -97,14 +97,24 @@ Generate a self signed certificate for your domain: `sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./nginx/nginx-selfsigned.key -out ./nginx/nginx-selfsigned.crt` -This command generates two files: -- the private key: `./nginx/nginx-selfsigned.key` -- the certificate file `./nginx/nginx-selfsigned.crt` +Replace the content of `./nginx/nginx.conf` with: -Both files need to be mapped as a volume to `/etc/nginx/ssl/`. +```txt +server { + listen 80; + listen [::]:80; + server_name _; + return 301 https://$host$request_uri; +} -Then you also need to adjust the `docker-compose.yml` file: -- comment the line `./nginx/nginx.conf:/etc/nginx/conf.d/default.conf` -- and uncomment the four lines below +server { + listen 443 ssl; + listen [::]:443 ssl; + include ssl/self-signed.conf; -Finally you need to adjust the `nginx/nginx.conf.https` and adjust the `server_name` to your domain. + location / { + proxy_pass http://grafana:3000/; + } +} + +``` diff --git a/docker-compose.yml b/docker-compose.yml index 5678a8e..9370baa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,14 +58,11 @@ services: container_name: nginx volumes: - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf - # Uncomment the four lines below to enable HTTPS - # - ./nginx/nginx.conf.https:/etc/nginx/conf.d/default.conf - # - ./nginx/nginx-selfsigned.key:/etc/nginx/ssl/nginx-selfsigned.key - # - ./nginx/nginx-selfsigned.crt:/etc/nginx/ssl/nginx-selfsigned.crt - # - ./nginx/self-signed.conf:/etc/nginx/ssl/self-signed.conf + - ./nginx/nginx-selfsigned.key:/etc/nginx/ssl/nginx-selfsigned.key + - ./nginx/nginx-selfsigned.crt:/etc/nginx/ssl/nginx-selfsigned.crt + - ./nginx/self-signed.conf:/etc/nginx/ssl/self-signed.conf ports: - 80:80 - 443:443 networks: - default - diff --git a/nginx/nginx-selfsigned.crt b/nginx/nginx-selfsigned.crt new file mode 100644 index 0000000..e69de29 diff --git a/nginx/nginx-selfsigned.key b/nginx/nginx-selfsigned.key new file mode 100644 index 0000000..e69de29 diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 448fa20..4b11ec2 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -1,7 +1,6 @@ server { listen 80; - root /usr/share/nginx/html; - index index.html index.htm; + listen [::]:80; location / { proxy_pass http://grafana:3000/; diff --git a/nginx/nginx.conf.https b/nginx/nginx.conf.https deleted file mode 100644 index 337a05f..0000000 --- a/nginx/nginx.conf.https +++ /dev/null @@ -1,22 +0,0 @@ -server { - listen 80; - - server_name 192.168.0.10; - - # Your domain - return 302 https://192.168.0.10; - -} - -server { - listen 443 ssl; - listen [::]:443 ssl; - include ssl/self-signed.conf; - - # Your domain - server_name 192.168.0.10; - - location / { - proxy_pass http://grafana:3000/; - } -}