How to hide a Response Server Header from a python application deployed in AKS as service?

Pranjali D. Deshbhratar 0 Reputation points
2024-08-29T19:19:54.22+00:00

Hello,

I have my Python flask application running in AKS as a service.

I want to hide the server information that is visible in Response headers under Server header.

Application specific changes are not working when deployed on AKS. Please suggest ways to hide server header while using Kubernetes as hosting agent.

User's image

Thank you!

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,073 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 10,036 Reputation points
    2024-08-29T21:16:11.2633333+00:00

    Hello Pranjali D. Deshbhratar,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to hide a Response Server Header from a python application deployed in AKS as service.

    You have several options to hide or remove the Server header in your response while running a Python Flask application on Azure Kubernetes Service (AKS), and since application-specific changes are not working, you can address this at the Kubernetes level using a few different methods as follows:

    Those links provide more details and steps in some cases.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

  2. Nikhil Duserla 2,025 Reputation points Microsoft Vendor
    2024-08-30T07:55:43.2733333+00:00

    Hi @Pranjali D. Deshbhratar,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    In additional with Sina Salam please go through these steps.

    Based on the shared information, I have understood that you are trying to eliminate the Server header from the AKS service response. Follow the below set of instructions on remove/eliminate the server header.

    Copy the existing python config file.

    Modify the python config file with using editor like nano or vi file name.

    Uncomment server_tokens off also add this more_clear_headers 'Server' and save the file.

    Create a startup script in any location inside home directory and run it.

    If you have any further queries, do let us know.

    If the answer is helpful, please click "Accept Answer" and "Upvote it."


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.