nginx.conf
user nginx;
worker_processes 8;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent $request_time $upstream_response_time "$http_referer" '
'"$http_user_agent"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
server_tokens off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# set_real_ip_from
include /etc/nginx/conf.d/app.conf;
}
app.conf
server {
listen 8000 default_server;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location /ping {
include uwsgi_params;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_pass unix:///var/data/recommendation/api/run/uwsgi.sock;
# uwsgi_pass 127.0.0.1:8000;
}
location / {
include uwsgi_params;
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_pass unix:///var/data/recommendation/api/run/uwsgi.sock;
# uwsgi_pass 127.0.0.1:8000;
}
}
Docker文件
FROM public.ecr.aws/nginx/nginx:latest as nginx
COPY recommendation/api/nginx/conf.d/ /etc/nginx/conf.d/
COPY recommendation/api/nginx/nginx.conf /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.conf
... some other django image build code
# nginx configs for ecs nginx container.
# nginx container uses this container's volume
COPY --from=nginx /etc/nginx /etc/nginx
VOLUME ["/etc/nginx"]
我使用Nginx + uwsgi + django + docker作为我的Web服务器。我需要访问日志来调查我在本地机器(localhost:8000)上的django服务器的empty_response问题。但是,我没有看到在所需位置创建的任何访问日志或错误日志。我放错了什么设置?
1条答案
按热度按时间2vuwiymt1#
在容器nginx的控制台上,尝试cat /etc/nginx/nginx。会议
您应该会看到类似error_log /var/log/nginx/error的内容。log notice; access_log /var/log/nginx/access。log main;
有关error_log和access_log的详细信息,请参阅nginx文档。