4

I'm new to AWS EBS. I'm trying to modify etc/nginx/nginx.conf. I just wanted to add a line in http{ underscores_in_headers on; } and I'm able to change by accessing the instance with IP using putty. But the problem is that when auto scaling scales the environment with new IP then the line http{ underscores_in_headers on; } will be removed from new instance.

So, I want when server deploy new snapshot/instance has to be similar as the main server or you can say with same configuration.

I tried to solve my issue with this link

Dominik
  • 1,016
  • 11
  • 30
Mishu
  • 269
  • 1
  • 3
  • 15
  • 2
    Have you already seen this? https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-proxy.html – Derek Aug 09 '18 at 13:02
  • 1
    yes, i have seen this but I'm not able to understand. How I have to do this. – Mishu Aug 09 '18 at 13:07
  • I understand that I need to add configuration file in .ebextensions but not able what I have to add to this file. – Mishu Aug 09 '18 at 13:09
  • 1
    You can check the nginx directives here: http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers. You should be able to add the underscores_in_headers option to the server directive that's in the example, or just create a top-level http directive. – Derek Aug 09 '18 at 13:16
  • while updating the EBS it is giving error Top level element in configuration file .ebextensions/nginx/nginx.config in application version app-2244-180809_185240 must be a map. Update the top level element in the configuration file. 2018-08-09 13:22:54 ERROR Failed to deploy application. – Mishu Aug 09 '18 at 13:24
  • @Derek that helped me a lot thank you for your help – Mishu Aug 10 '18 at 05:58

2 Answers2

1

Step 1 To edit the configuration in AWS ElasticBean of nginx you need to add the configuration file in .ebextensions

to this add folder .ebextensions/nginx/ create proxy.config file

files:
  /etc/nginx/conf.d/proxy.conf:
    mode: "000644"
    owner: root
    group: root
    content: |
      underscores_in_headers on;

it will start accepting header with underscores.

Step 2

In case if it not accepting header with underscores then access your instance with ssh and run the following command.

sudo service nginx reload

Hope it helps.

JBaczuk
  • 13,886
  • 10
  • 58
  • 86
Prateek218
  • 664
  • 7
  • 21
0

stack isn't letting me comment because I'm a noobie. Prateek really helped out, just one small modification to his solution for the proxy.config file and it should work! Don't forget to indent /etc/nginx/conf.d/proxy.conf: as well! Further info here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-proxy.html

files:
  /etc/nginx/conf.d/proxy.conf:
    mode: "000644"
    owner: root
    group: root
    content: |
      underscores_in_headers on;
LoopBoi
  • 453
  • 1
  • 4
  • 6