got caching working

This commit is contained in:
Adam 2023-09-06 19:48:14 -05:00
parent 3fabbe0fec
commit cf460a79f9
4 changed files with 40 additions and 1 deletions

View File

@ -10,3 +10,4 @@ services:
volumes:
- ./nginx-conf/default.conf.template:/etc/nginx/templates/default.conf.template
- ./nginx_logs:/var/log/nginx
- ./nginx-conf/nginx.conf:/etc/nginx/nginx.conf

View File

@ -14,7 +14,7 @@ Response: <span id="response"></span>
<script>
$(function() {
$.ajax({
url: 'http://localhost:8080/service?url=http://192.168.2.214:3000/',
url: 'http://localhost:8080/service?url=https://google.com/',
success: res => {
$('#response').text(res);
},

View File

@ -5,6 +5,10 @@ server {
resolver 127.0.0.11;
proxy_cache mycache;
proxy_cache_valid 200 15s;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
@ -13,5 +17,6 @@ server {
proxy_pass $arg_url;
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin $http_origin;
}
}

33
nginx-conf/nginx.conf Normal file
View File

@ -0,0 +1,33 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
proxy_cache_path /var/cache/nginx/mycache keys_zone=mycache:10m;
include /etc/nginx/conf.d/*.conf;
}