Reputation: 23322
In my Elastic Beanstalk instance, I am able to select Nginx to be the proxy in front of my instance.
However, it gives no indication of where the config file (i.e. /nginx/conf.d/proxy.conf
) might be, nor how to make changes to it.
I found some documentation that mentions the conf file, but offers no information on how to see it live or make changes to it.
Does anyone know how to read and edit the nginx conf on an Elastic Beanstalk application?
Upvotes: 0
Views: 107
Reputation: 17455
Generally you don't want to change the files on an Elastic Beanstalk instance. The advantage of that environment is that you can spin up new instances as needed and you don't need to touch them.
You can customize quite a bit about Elastic Beanstalk machines using the ebextensions method. Basically this is a script and file structure that gives you the ability to change your environment. Be warned though that your best way of debugging this is to enable SSH into the machine and watch what the startup scripts are doing. I feel that Amazon hasn't documented this process very well and watching what it does is still the easiest way.
I use the Java Elastic Beanstalk and have to change the port that is proxied from 5000 to 8080. I have a file that, in my environment, replaces the existing proxy file. In .ebextensions/nginx/conf.d/elasticbeanstalk
in my Elastic Beanstalk distribution file I include the following as 00_application.conf
:
#
# default is 404 - no need to allow anything else
#
location / {
return 404;
}
#
# this is our default url path prefix
#
location /integration {
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;
}
This is for a REST service that only exposed /integration
. The key is that I had to get the initial file from logging into the machine to see how my environment was configured. Depending on the Elastic Beanstalk environment type you pick your setup may be different. In the Java world, for example, there is the Tomcat type and the Java application type and the configuration of the two is very different.
Upvotes: 1