add a header to incoming http request in a server

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have a ubuntu 16.04 server. It runs nginx webserver for the frontend part. Also the backend application runs in the same server.



Now the requirement is to add header to incoming http requests. And we need to add header to the request coming from specific sources (IPs) only.



For Example:



users hit the following URL:



http://abc.example.com/live/xyz


As soon as the server receives this request, we need to change it to:



http://abc.example.com/live/xyz?token=akjshdfhkajshkj


How can we achieve this in ubuntu?As I searched I have found that HAproxy and nginx itself can be used to add header or is there any other better alternative. It would be of great help if someone could please help to get a solution for this.



Thanks in advance!







share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a ubuntu 16.04 server. It runs nginx webserver for the frontend part. Also the backend application runs in the same server.



    Now the requirement is to add header to incoming http requests. And we need to add header to the request coming from specific sources (IPs) only.



    For Example:



    users hit the following URL:



    http://abc.example.com/live/xyz


    As soon as the server receives this request, we need to change it to:



    http://abc.example.com/live/xyz?token=akjshdfhkajshkj


    How can we achieve this in ubuntu?As I searched I have found that HAproxy and nginx itself can be used to add header or is there any other better alternative. It would be of great help if someone could please help to get a solution for this.



    Thanks in advance!







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a ubuntu 16.04 server. It runs nginx webserver for the frontend part. Also the backend application runs in the same server.



      Now the requirement is to add header to incoming http requests. And we need to add header to the request coming from specific sources (IPs) only.



      For Example:



      users hit the following URL:



      http://abc.example.com/live/xyz


      As soon as the server receives this request, we need to change it to:



      http://abc.example.com/live/xyz?token=akjshdfhkajshkj


      How can we achieve this in ubuntu?As I searched I have found that HAproxy and nginx itself can be used to add header or is there any other better alternative. It would be of great help if someone could please help to get a solution for this.



      Thanks in advance!







      share|improve this question














      I have a ubuntu 16.04 server. It runs nginx webserver for the frontend part. Also the backend application runs in the same server.



      Now the requirement is to add header to incoming http requests. And we need to add header to the request coming from specific sources (IPs) only.



      For Example:



      users hit the following URL:



      http://abc.example.com/live/xyz


      As soon as the server receives this request, we need to change it to:



      http://abc.example.com/live/xyz?token=akjshdfhkajshkj


      How can we achieve this in ubuntu?As I searched I have found that HAproxy and nginx itself can be used to add header or is there any other better alternative. It would be of great help if someone could please help to get a solution for this.



      Thanks in advance!









      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 27 at 8:00

























      asked Feb 26 at 10:05









      Samin Munankarmi

      216




      216




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Header means we need to add the first line to file.



          sed -i 'li header content' filename.


          header conent can be anything as per your requirement.



          It would be helpful if you post sample input and output required






          share|improve this answer




















          • hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
            – Samin Munankarmi
            Feb 27 at 9:01










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426639%2fadd-a-header-to-incoming-http-request-in-a-server%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Header means we need to add the first line to file.



          sed -i 'li header content' filename.


          header conent can be anything as per your requirement.



          It would be helpful if you post sample input and output required






          share|improve this answer




















          • hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
            – Samin Munankarmi
            Feb 27 at 9:01














          up vote
          0
          down vote













          Header means we need to add the first line to file.



          sed -i 'li header content' filename.


          header conent can be anything as per your requirement.



          It would be helpful if you post sample input and output required






          share|improve this answer




















          • hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
            – Samin Munankarmi
            Feb 27 at 9:01












          up vote
          0
          down vote










          up vote
          0
          down vote









          Header means we need to add the first line to file.



          sed -i 'li header content' filename.


          header conent can be anything as per your requirement.



          It would be helpful if you post sample input and output required






          share|improve this answer












          Header means we need to add the first line to file.



          sed -i 'li header content' filename.


          header conent can be anything as per your requirement.



          It would be helpful if you post sample input and output required







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 26 at 14:23









          Praveen Kumar BS

          1,010128




          1,010128











          • hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
            – Samin Munankarmi
            Feb 27 at 9:01
















          • hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
            – Samin Munankarmi
            Feb 27 at 9:01















          hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
          – Samin Munankarmi
          Feb 27 at 9:01




          hello @Praveen Kumar BS I have edited the question by adding an example. hope this will explain the requirement.
          – Samin Munankarmi
          Feb 27 at 9:01












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426639%2fadd-a-header-to-incoming-http-request-in-a-server%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay