Search code examples
amazon-web-servicesnginxamazon-elastic-beanstalk

nginx block not getting triggered


I have this file:

.ebextensions/nginx/conf.d/rewrite.config

files:
  "/etc/nginx/conf.d/rewrite.config":
    mode: "000755"
    owner: root
    group: root
    content: |
      location / {
          error_log "Rewrite rule triggered for URL: $uri" info;
          rewrite ^([^#]*)%23(.*)$ $1#$2 permanent;
      }


When I deploy this to Elastic Beanstalk using eb deploy, then make requests to the web app, this part is not triggered.

Is the code above correct? What am I doing wrong?

Note: Purpose of code is to replace %23 with #


Solution

  • Here's what I have discovered yesterday and ended up working for me.

    Create this file:

    .platform/nginx/conf.d/elasticbeanstalk/00_application.conf
    

    This way you can override the default / block. Other solutions didn't work.

    Hope this helps me and other people in the future!