swagger-api / swagger-api/swagger-ui

Define nginx headers using environment variables or config.json for Docker deployment

Open
#8,379 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Content & configuration

Swagger/OpenAPI definition:
N/A

Swagger-UI configuration options:
BASE_URL
CONFIG_URL
OAUTH_USE_PKCE

Is your feature request related to a problem?

It would be useful to be able to define custom response headers, both for configuration and security purposes, without customizing the docker image to do so. In particular setting headers like X-Frame-Options, Strict-Transport-Security, and X-Robots-Tag.

Describe the solution you'd like

My ideal solution would be one or both of the following:
a. Add a new array config parameter to my config.json file called responseHeaders that would allow an array of key value pairs to be defined which would be added to the headers of each response. Something like:

{
    "responseHeaders": [
        {
            "X-Frame-Options": "SAMEORIGIN"
        },
        {
            "X-Robots-Tag": "noindex"
        }
    ]
}

b. Perhaps an environment variable that allows similar headers to be defined which might look something like this:
"RESPONSE_HEADERS": "X-Frame-Options=SAMEORIGIN,X-Robots-Tag=noindex"

Describe alternatives you've considered

The only viable alternative I'm aware of would be to make my own docker image, make a copy of your nginx.conf file and modify it to add the headers in question. This is less desirable as it creates the opportunity for configuration drift as things are changed in the official swagger-ui Docker image.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Docker deployment configuration and the referenced nginx.conf, then inspect how config.json and environment variables are currently handled. Define and document the supported custom response-header configuration, and verify that configured headers appear on Docker-served responses without requiring a custom image.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, nginx
Domain
devops, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.