
[英]AWS Elastic Beanstalk .ebestensions/nginx/nginx.conf not overriding AWS' default nginx.conf
[英]What are the syntax rules for the nginx configuration files (00_application.conf and 01_static.conf) for this instance generated by AWS beanstalk?
由beantalk生成的实例,该实例上的nginx默认使用这两个配置文件。 (00_application.conf和01_static.conf)
这两个文件的路径如下:
[root@ip-10-0-0-145 elasticbeanstalk]# pwd
/etc/nginx/conf.d/elasticbeanstalk
[root@ip-10-0-0-145 elasticbeanstalk]# ls
00_application.conf 01_static.conf healthd.conf
[root@ip-10-0-0-145 elasticbeanstalk]# cat 00_application.conf
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
在同一实例中/etc/nginx/nginx.conf的内容为:
# Elastic Beanstalk Nginx Configuration File
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 67129;
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"';
include conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 80 default_server;
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip on;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/*.conf;
}
}
我进行了测试,目的是使用/etc/nginx/nginx.conf而不是00_application.conf,但是它报告错误:nginx:/ etc / nginx / conf中不允许使用“用户”指令.D / elasticbeanstalk / 00_application.conf:3
[root@ip-10-0-0-145 elasticbeanstalk]# ls
00_application.conf 01_static.conf healthd.conf
[root@ip-10-0-0-145 elasticbeanstalk]# mv 00_application.conf
00_application.conf_20181126bak
[root@ip-10-0-0-145 elasticbeanstalk]# cp /etc/nginx/nginx.conf
00_application.conf
[root@ip-10-0-0-145 elasticbeanstalk]# /etc/init.d/nginx stop
[root@ip-10-0-0-145 elasticbeanstalk]# /etc/init.d/nginx start
Starting nginx: nginx: [emerg] "user" directive is not allowed here in /etc/nginx/conf.d/elasticbeanstalk/00_application.conf:3
问题1:
为什么/etc/nginx/conf.d/elasticbeanstalk/00_application.conf中不允许使用“用户”指令?
问题2:
Nginx配置文件的语法规则是什么:/etc/nginx/conf.d/elasticbeanstalk/00_application.conf和/etc/nginx/conf.d/elasticbeanstalk/01_static.conf?
问题3:
有什么办法可以使beantalk生成的实例上的nginx配置文件为/etc/nginx/nginx.conf?
此链接如何为nginx位置指令配置.ebextensions? 可以是问题3的答案吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.