commit 93b0b258523ca16bb246109b6fd609d579ffcc79 Author: root Date: Fri Jul 26 00:36:17 2024 +0300 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..77176b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ssl/* diff --git a/0010-cache.conf b/0010-cache.conf new file mode 100644 index 0000000..baebef4 --- /dev/null +++ b/0010-cache.conf @@ -0,0 +1,106 @@ +server { + listen 80; + server_name cdn.playemulator.io www.playemulator.io static.playemulator.io images.playemulator.io; + root /srv/playemulator/data; + index index.html index.htm; + # access_log /srv/steamcache/logs/access.log steamcache-default; + # error_log /srv/steamcache/logs/error.log; + proxy_temp_path /tmp/nginx/ 1 2; + + resolver 8.8.8.8; + +# location / { +# try_files $uri @mirror; +# # access_log /srv/steamcache/logs/access.log steamcache-local; +# } + + location / { + proxy_next_upstream error timeout http_404; + proxy_pass http://$host$request_uri; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + add_header X-Mirror-Upstream-Status $upstream_status; + add_header X-Mirror-Upstream-Response-Time $upstream_response_time; + add_header X-Mirror-Status $upstream_cache_status; + add_header Host $host; + # access_log /srv/steamcache/logs/access.log steamcache-other; + } + + location @mirror { + proxy_store on; + proxy_store_access user:rw group:rw all:r; + proxy_next_upstream error timeout http_404; + proxy_pass https://$host; +#$request_uri; + proxy_redirect off; +# proxy_set_header Host $host; +# proxy_set_header X-Real-IP $remote_addr; +# proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for; +# add_header X-Mirror-Upstream-Status $upstream_status; +# add_header X-Mirror-Upstream-Response-Time $upstream_response_time; +# add_header X-Mirror-Status $upstream_cache_status; + # access_log /srv/steamcache/logs/access.log steamcache-remote; + } +} + +server { + listen 443 ssl http2; + proxy_cache default_cache; + + server_name cdn.playemulator.io www.playemulator.io static.playemulator.io images.playemulator.io; +# ssl_certificate www.example.com.chained.crt; +# ssl_certificate_key www.example.com.key; + ssl_certificate /etc/ssl/local/cache.chained.crt; + ssl_certificate_key /etc/ssl/local/cache.key; + + root /srv/playemulator/data; + index index.html index.htm; + # access_log /srv/steamcache/logs/access.log steamcache-default; + # error_log /srv/steamcache/logs/error.log; + proxy_temp_path /tmp/nginx/ 1 2; + + resolver 8.8.8.8; + +# location /uploads/games/ { +# try_files $uri @mirror; +# access_log /srv/playemulator/logs/access.log steamcache-local; +# } + + location / { + proxy_next_upstream error timeout http_404; + proxy_pass https://$host$request_uri; + proxy_ssl_verify off; + + proxy_ssl_server_name on; + +proxy_ignore_headers "Set-Cookie"; +proxy_hide_header "Set-Cookie"; +proxy_buffering on; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + add_header X-Mirror-Upstream-Status $upstream_status; + add_header X-Mirror-Upstream-Response-Time $upstream_response_time; + add_header X-Mirror-Status $upstream_cache_status; + add_header Host $host; + # access_log /srv/steamcache/logs/access.log steamcache-other; + } + + location @mirror { + proxy_store on; + proxy_store_access user:rw group:rw all:r; + proxy_next_upstream error timeout http_404; + proxy_pass https://$host$request_uri; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for; + add_header X-Mirror-Upstream-Status $upstream_status; + add_header X-Mirror-Upstream-Response-Time $upstream_response_time; + add_header X-Mirror-Status $upstream_cache_status; + # access_log /srv/steamcache/logs/access.log steamcache-remote; + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ab8348c --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +all: + echo OK + +install: + mkdir /srv/playemulator/data -p + chown www-data:www-data -R /srv/playemulator/data + cp -vf 0010-cache.conf /etc/nginx/sites-available/ + cp -vf cache-dir.conf /etc/nginx/conf.d/ + cd /etc/nginx/sites-enabled && ln -s ../sites-available/0010-cache.conf;true + +install-cert: + mkdir /etc/ssl/local -p + cat ssl/cert.pem ssl/chain.pem > /etc/ssl/local/cache.chained.crt + cat ssl/key.pem > /etc/ssl/local/cache.key + +start: + systemctl start nginx +reload: + systemctl reload nginx +restart: stop start + +stop: + systemctl stop nginx +enable: + systemctl enable nginx +disable: + systemctl disable nginx diff --git a/README.md b/README.md new file mode 100644 index 0000000..baffc1b --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +## + +* diff --git a/cache-dir.conf b/cache-dir.conf new file mode 100644 index 0000000..2ba87ad --- /dev/null +++ b/cache-dir.conf @@ -0,0 +1,9 @@ +proxy_cache_path /srv/playemulator/cache levels=1:2 keys_zone=default_cache:10m max_size=2g + inactive=120m use_temp_path=off; +proxy_cache_key "$scheme$request_method$host$request_uri"; +proxy_cache_valid 200 302 129600m; + +#proxy_cache_methods GET HEAD POST; + +log_format steamcache-local '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" LOCAL'; + diff --git a/decrypt-key.sh b/decrypt-key.sh new file mode 100755 index 0000000..197889f --- /dev/null +++ b/decrypt-key.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +openssl rsa -in ssl/key.pem.encrypted -out ssl/key.pem diff --git a/ssl/.placeholder b/ssl/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..02d45d5 --- /dev/null +++ b/test.sh @@ -0,0 +1 @@ +curl 'https://static.playemulator.io/uploads/games/202011/kawasaki-superbike-challenge.smc?ver=104' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'Origin: https://load.retroemulator.com' -H 'Connection: keep-alive' -H 'Referer: https://load.retroemulator.com/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: cross-site' -H 'TE: trailers' --output /dev/null -k