0
EB에서 내 nginx 역 프록시 구성을 변경해야합니다. 내 로컬 환경에서 모두 잘 구성되어 있고 작동하지만 proxy_cache_path 및 다른 것들을 변경하려고하면 작동하지 않습니다.AWS Elastic Beanstalk에서 nginx 캐시 구성
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
proxy_cache_path /cache/nginx levels=1:2 keys_zone=cache_zone_name:10m;
server {
listen 80;
server_name mydomain.app, www.mydomain.app;
#charset koi8-r;
#access_log logs/host.access.log main;
location/{
#root html;
#index index.html index.htm;
#Config proxy inverse cache
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# Add cache debugging header
add_header X-Cache-Status $upstream_cache_status;
# Configure cache
proxy_cache cache_zone_name;
proxy_cache_valid any 1m;
proxy_cache_key $scheme$host$request_uri;
}
#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 html;
}
}
include servers/*;
}
나는 공식 문서에서 받아 내 인스턴스 과 비교 한 :
이 내 로컬 구성 ( nginx.conf )이며, 여기서 중요한 것은 proxy_cache_path하고 구성 캐시 섹션입니다. ebextensions/방법 proxy.config : 나는 폴더 구성한
files:
/etc/nginx/conf.d/proxy.conf:
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:8081;
keepalive 256;
}
server {
listen 8080;
# proxy_cache_path /home levels=1:2 keys_zone=cache_zone_name:10m;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log main;
location/{
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
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 cache debugging header
add_header X-Cache-Status $upstream_cache_status;
# Configure cache
# proxy_cache cache_zone_name;
# proxy_cache_valid any 1m;
# proxy_cache_key $scheme$host$request_uri;
}
gzip on;
gzip_comp_level 4;
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location /public {
alias /var/app/current/public;
}
}
container_commands:
removeconfig:
command: "rm -f /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"
/홈 CACH에 대한 ing이고, proxy_cache_path 및 Configure Cache 섹션의 주석을 제거하면 전개가 실패합니다.
아이디어가 있으십니까? 나는 결과없이 2 시간 이상을 보냈다 ... 감사합니다 !!