Selaa lähdekoodia

add dockerfile and nginx.conf

Bay 5 vuotta sitten
vanhempi
commit
0eb1ffc50f
2 muutettua tiedostoa jossa 133 lisäystä ja 0 poistoa
  1. 10 0
      Dockerfile
  2. 123 0
      nginx.conf

+ 10 - 0
Dockerfile

@@ -0,0 +1,10 @@
+FROM node:alpine AS base
+# Copy project file
+COPY . .
+# Build project
+RUN npm i && npm run generate
+
+
+FROM nginx:latest
+COPY nginx.conf /etc/nginx/
+COPY --from=base dist /var/www/p.seec.seecoder.cn/public

+ 123 - 0
nginx.conf

@@ -0,0 +1,123 @@
+# Generated by nginxconfig.io
+# https://www.digitalocean.com/community/tools/nginx?domains.0.server.redirectSubdomains=false&domains.0.https.https=false&domains.0.php.php=false&domains.0.reverseProxy.reverseProxy=true&domains.0.reverseProxy.path=%2Fapi&domains.0.routing.index=index.html&domains.0.routing.fallbackHtml=true&domains.0.routing.fallbackPhp=false&global.nginx.user=nginx&global.nginx.pid=%2Fvar%2Frun%2Fnginx.pid&global.docker.dockerfile=true&global.tools.modularizedStructure=false&global.tools.symlinkVhost=false&global.app.lang=zhCN
+
+user                 nginx;
+pid                  /var/run/nginx.pid;
+worker_processes     auto;
+worker_rlimit_nofile 65535;
+
+# Load modules
+include              /etc/nginx/modules-enabled/*.conf;
+
+events {
+    multi_accept       on;
+    worker_connections 65535;
+}
+
+http {
+    charset                utf-8;
+    sendfile               on;
+    tcp_nopush             on;
+    tcp_nodelay            on;
+    server_tokens          off;
+    log_not_found          off;
+    types_hash_max_size    2048;
+    types_hash_bucket_size 64;
+    client_max_body_size   16M;
+
+    # MIME
+    include                mime.types;
+    default_type           application/octet-stream;
+
+    # Logging
+    access_log             /var/log/nginx/access.log;
+    error_log              /var/log/nginx/error.log warn;
+
+    # Connection header for WebSocket reverse proxy
+    map $http_upgrade $connection_upgrade {
+        default upgrade;
+        ""      close;
+    }
+
+    # Load configs
+    include /etc/nginx/conf.d/*.conf;
+
+    # example.com
+    server {
+        listen                             80;
+        listen                             [::]:80;
+        server_name                        p.seec.seecoder.cn;
+        root                               /var/www/p.seec.seecoder.cn/public;
+
+        # security headers
+        add_header X-Frame-Options         "SAMEORIGIN" always;
+        add_header X-XSS-Protection        "1; mode=block" always;
+        add_header X-Content-Type-Options  "nosniff" always;
+        add_header Referrer-Policy         "no-referrer-when-downgrade" always;
+        add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
+
+        # . files
+        location ~ /\.(?!well-known) {
+            deny all;
+        }
+
+        # index.html fallback
+        location / {
+            try_files $uri $uri/ /index.html;
+        }
+
+        # reverse proxy
+        location /api {
+            proxy_pass                         http://server.p.seec.seecoder.cn;
+            proxy_http_version                 1.1;
+            proxy_cache_bypass                 $http_upgrade;
+
+            # Proxy headers
+            proxy_set_header Upgrade           $http_upgrade;
+            proxy_set_header Connection        $connection_upgrade;
+            proxy_set_header Host              $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 X-Forwarded-Host  $host;
+            proxy_set_header X-Forwarded-Port  $server_port;
+
+            # Proxy timeouts
+            proxy_connect_timeout              60s;
+            proxy_send_timeout                 60s;
+            proxy_read_timeout                 60s;
+        }
+
+        # favicon.ico
+        location = /favicon.ico {
+            log_not_found off;
+            access_log    off;
+        }
+
+        # robots.txt
+        location = /robots.txt {
+            log_not_found off;
+            access_log    off;
+        }
+
+        # assets, media
+        location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
+            expires    7d;
+            access_log off;
+        }
+
+        # svg, fonts
+        location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
+            add_header Access-Control-Allow-Origin "*";
+            expires    7d;
+            access_log off;
+        }
+
+        # gzip
+        gzip            on;
+        gzip_vary       on;
+        gzip_proxied    any;
+        gzip_comp_level 6;
+        gzip_types      text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
+    }
+}