diff --git a/Dockerfile-4bytes b/Dockerfile-4bytes new file mode 100644 index 0000000..9d308d9 --- /dev/null +++ b/Dockerfile-4bytes @@ -0,0 +1,3 @@ +FROM nginx:1.21.1-alpine +COPY 4bytes/signatures /usr/share/nginx/html/ +COPY nginx-4bytes.conf /etc/nginx/conf.d/default.conf diff --git a/nginx-4bytes.conf b/nginx-4bytes.conf new file mode 100644 index 0000000..6060f2b --- /dev/null +++ b/nginx-4bytes.conf @@ -0,0 +1,50 @@ +server { + listen 80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + + # Base on: https://michielkalkman.com/snippets/nginx-cors-open-configuration/ + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + # + # Om nom nom cookies + # + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; + + # + # Custom headers and headers various browsers *should* be OK with but aren't + # + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + + # + # Tell client that this pre-flight info is valid for 20 days + # + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; + } + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + +} \ No newline at end of file diff --git a/package.json b/package.json index 841d6f1..7191a55 100644 --- a/package.json +++ b/package.json @@ -42,9 +42,11 @@ "build": "craco build", "test": "craco test", "eject": "react-scripts eject", - "serve-4bytes": "serve -p 3001 -C -c serve-4bytes.json", + "start-4bytes": "docker run --rm -p 3001:80 --name otterscan-4bytes -d otterscan/4bytes", + "stop-4bytes": "docker stop otterscan-4bytes", "serve-trustwallet-assets": "serve -p 3002 -C -c serve-trustwallet-assets.json", - "serve": "serve -s build" + "serve": "serve -s build", + "build-docker-4bytes": "docker build -t otterscan/4bytes -f Dockerfile-4bytes ." }, "eslintConfig": { "extends": [