From 9b2d37854a8ca5e81d46fba60e90b4969e3ff785 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Thu, 28 Nov 2024 14:18:20 +0000 Subject: [PATCH] add: ip-gate service to container vpn --- roles/nextcloud/nginx-nextcloud.conf | 132 ++++++++++++++++++ roles/openvpn/tasks/main.yaml | 19 ++- roles/openvpn/templates/atlantis-ip-gate.yaml | 23 +++ 3 files changed, 169 insertions(+), 5 deletions(-) create mode 100644 roles/nextcloud/nginx-nextcloud.conf create mode 100644 roles/openvpn/templates/atlantis-ip-gate.yaml diff --git a/roles/nextcloud/nginx-nextcloud.conf b/roles/nextcloud/nginx-nextcloud.conf new file mode 100644 index 0000000..2f42ab0 --- /dev/null +++ b/roles/nextcloud/nginx-nextcloud.conf @@ -0,0 +1,132 @@ +server { + listen 80; + listen [::]:80; + listen 443 ssl http2; + listen [::]:443 ssl http2; + + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header X-Download-Options noopen; + add_header X-Permitted-Cross-Domain-Policies none; + add_header Referrer-Policy no-referrer; + + ssl_certificate /etc/letsencrypt/live/nextcloud.atlantishq.de/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/nextcloud.atlantishq.de/privkey.pem; + + # Remove X-Powered-By, which is an information leak + fastcgi_hide_header X-Powered-By; + + # Path to the root of your installation + root /var/www/nextcloud/; + + proxy_read_timeout 900; + proxy_connect_timeout 300; + proxy_send_timeout 900; + + set_real_ip_from 192.168.122.1; + real_ip_header X-Forwarded-For; + real_ip_recursive on; + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location ^~ /.well-known { + # The following 6 rules are borrowed from `.htaccess` + + location /.well-known/acme-challenge/ { + auth_basic off; + allow all; + alias /var/www/.well-known/acme-challenge/; + } + location = /.well-known/carddav { return 302 /remote.php/dav/; } + location = /.well-known/caldav { return 302 /remote.php/dav/; } + # Anything else is dynamically handled by Nextcloud + location ^~ /.well-known { return 302 /index.php$uri; } + + try_files $uri $uri/ =404; + } + + + # set max upload size + client_max_body_size 1G; + fastcgi_buffers 64 4K; + + # Enable gzip but do not remove ETag headers + gzip on; + gzip_vary on; + gzip_comp_level 4; + gzip_min_length 256; + gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; + gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; + + # Uncomment if your server is build with the ngx_pagespeed module + # This module is currently not supported. + #pagespeed off; + + location / { + rewrite ^ /index.php; + } + + location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { + deny all; + } + location ~ ^\/(?:autotest|occ|issue|indie|db_|console) { + deny all; + } + + location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) { + fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; + set $path_info $fastcgi_path_info; + try_files $fastcgi_script_name =404; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $path_info; + fastcgi_param HTTPS on; + # Avoid sending the security headers twice + fastcgi_param modHeadersAvailable true; + # Enable pretty urls + fastcgi_param front_controller_active true; + fastcgi_pass unix:/var/run/php/php-fpm.sock; + fastcgi_intercept_errors on; + fastcgi_request_buffering off; + + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag "noindex,nofollow"; + add_header X-Download-Options noopen; + add_header X-Permitted-Cross-Domain-Policies none; + add_header Referrer-Policy no-referrer; + } + + location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { + try_files $uri/ =404; + index index.php; + } + + # Adding the cache control header for js, css and map files + # Make sure it is BELOW the PHP block + location ~ \.(?:css|js|woff2?|svg|gif|map)$ { + try_files $uri /index.php$request_uri; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag "noindex,nofollow"; + add_header X-Download-Options noopen; + add_header X-Permitted-Cross-Domain-Policies none; + add_header Referrer-Policy no-referrer; + + # Optional: Don't log access to assets + access_log off; + } + + location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ { + try_files $uri /index.php$request_uri; + # Optional: Don't log access to other assets + access_log off; + } + +} diff --git a/roles/openvpn/tasks/main.yaml b/roles/openvpn/tasks/main.yaml index 78110f2..83e8644 100644 --- a/roles/openvpn/tasks/main.yaml +++ b/roles/openvpn/tasks/main.yaml @@ -60,20 +60,29 @@ - name: Create compose directories file: - name: "/opt/certificate-manager/" + name: "/opt/{{ item }}/" state: directory + with_items: + - certificate-manager + - atlantis-ip-gate - name: Copy compose templates template: - src: "certificate-manager.yaml" - dest: "/opt/certificate-manager/" + src: "{{ item }}.yaml" + dest: "/opt/{{ item }}/" + with_items: + - certificate-manager + - atlantis-ip-gate - name: Deploy compose templates community.docker.docker_compose: - project_src: "/opt/certificate-manager/" + project_src: "/opt/{{ item }}/" pull: true files: - - "certificate-manager.yaml" + - "{{ item }}.yaml" + with_items: + - certificate-manager + - atlantis-ip-gate # setup oauth proxy # - name: include services ports diff --git a/roles/openvpn/templates/atlantis-ip-gate.yaml b/roles/openvpn/templates/atlantis-ip-gate.yaml new file mode 100644 index 0000000..20cc2a8 --- /dev/null +++ b/roles/openvpn/templates/atlantis-ip-gate.yaml @@ -0,0 +1,23 @@ +version: '3' +services: + flask: + restart: always + image: harbor-registry.atlantishq.de/atlantishq/atlantis-ip-gate-listener:latest + ports: + - 8001:5000 + volumes: + - vpn-gate-data:/app/data/ + environment: + - APP_SECRET=jeanswochenendegeschichte + nginx: + restart: always + image: harbor-registry.atlantishq.de/atlantishq/atlantis-ip-gate-nginx:latest + volumes: + - vpn-gate-data:/data/ + ports: + - 8000:8000 + environment: + - TARGET=http://172.16.1.15:8096 + +volumes: + vpn-gate-data: