diff --git a/nginx/default b/nginx/default new file mode 100644 index 0000000..c8d5257 --- /dev/null +++ b/nginx/default @@ -0,0 +1,76 @@ +server { + listen 80; + + + location / { + proxy_pass http://localhost:8080/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + #### When using Let's Encrypt Only #### + location /.well-known/acme-challenge/ { + root /var/www/montana2000.ddns.net; + } + + location /owncloud { + proxy_pass http://localhost:8088/owncloud; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + +} + +server { + listen 84; + server_name montana2000.ddns.net; + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl; + server_name montana2000.ddns.net; + + ssl_certificate /etc/letsencrypt/live/montana2000.ddns.net/fullchain.pem; # or /etc/ssl/openhab.crt + ssl_certificate_key /etc/letsencrypt/live/montana2000.ddns.net/privkey.pem; # or /etc/ssl/openhab.key + #add_header Strict-Transport-Security "max-age=31536000"; # Remove if using self-signed and are having trouble. + + location / { + proxy_pass http://localhost:8080/; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + satisfy any; + allow 192.168.0.0/24; + allow 127.0.0.1; + deny all; + auth_basic "Username and Password Required"; + auth_basic_user_file /etc/nginx/.htpasswd; + } + + location /owncloud { + proxy_pass http://localhost:8088/owncloud; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + satisfy any; + allow 192.168.0.0/24; + allow 127.0.0.1; + } + + #### When using Let's Encrypt Only #### + location /.well-known/acme-challenge/ { + root /var/www/montana2000.ddns.net; + } +} + diff --git a/nginx/docker-compose.yml b/nginx/docker-compose.yml new file mode 100644 index 0000000..aff5b4c --- /dev/null +++ b/nginx/docker-compose.yml @@ -0,0 +1,12 @@ + +version: '2' +services: + nginx: + image: nginx:latest + ports: + - "80:80" + - "443:443" + volumes: + - D:\dev\docker\docker-compose\nginx\nginx.conf:/etc/nginx/nginx.conf + restart: always + network_mode: host \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..ea3c03e --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,112 @@ +user www-data; +worker_processes auto; +pid /run/nginx.pid; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # SSL Settings + ## + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE + ssl_prefer_server_ciphers on; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # Virtual Host Configs + ## + server { + listen 80; + + # Docker DNS + resolver 127.0.0.11; + server_name montana2000.ddns.net; + + location /gitea/ { + proxy_pass http://host.docker.internal:3000/; + } + + location /nextcloud/ { + proxy_pass http://host.docker.internal:8080/; + } + + location / { + proxy_pass http://192.168.178.36:8088/; + } + + location /openhab/ { + proxy_pass http://192.168.178.36:8080/; + } + + location /fhem/ { + proxy_pass https://montana2000.ddns.net:8083/fhem/; + } + + location /owncloud/ { + proxy_pass http://192.168.178.36:8088/owncloud/; + } + } +} + + +#mail { +# # See sample authentication script at: +# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript +# +# # auth_http localhost/auth.php; +# # pop3_capabilities "TOP" "USER"; +# # imap_capabilities "IMAP4rev1" "UIDPLUS"; +# +# server { +# listen localhost:110; +# protocol pop3; +# proxy on; +# } +# +# server { +# listen localhost:143; +# protocol imap; +# proxy on; +# } +#}