Reputation: 4250
I've created my node.js app on ebs with two subrouters 'foo' and 'bar', currently accessible via 'example.com/foo' and 'example.com/bar'.
I'd like the reverse proxy of ebs to forward the subdomains "foo.example.com" and "bar.example.com" to these subfolders...
i.e. "foo.example.com/xxx" to "example.com/foo/xxx" "bar.example.com/yyy" to "example.com/bar/yyy" etc.
I know how to configure nginx to do this, but I can't figure out to access the nginx config files on EBS...
Someone asked exactly the same thing over a year ago, but it seems EBS has developped a good deal since... would just like to know if this sort of thing is now doable.
Upvotes: 3
Views: 2444
Reputation: 5827
you can use Configuration File to customize your nginx configuration.
.ebextensions
directory in the top-level of your source bundle./your_app/.ebextensions/custom.config
. Type the following inside the configuration file to configure forward settings. (I have created a gist)files:
"/etc/nginx/conf.d/custom.conf" :
content: |
server {
listen 8080;
server_name foo.chief-motp.com;
location / {
proxy_pass http://nodejs/foo/;
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;
}
location /public {
alias /var/app/current/public;
}
}
server {
listen 8080;
server_name bar.chief-motp.com;
location / {
proxy_pass http://nodejs/bar/;
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;
}
location /public {
alias /var/app/current/public;
}
}
Another methodology to customize Elastic Beanstalk EC2 instances is using Custom AMI. For more information, you can refer my post.
Upvotes: 6