Skip to content

http-server can be configured with more flexible settings, especially regarding proxy functionality #906

@JiayangShen

Description

@JiayangShen

What's the problem this feature will solve?

http-server now has the capability to configure proxy functions; however, this feature is quite basic and can only forward all unhandled HTTP requests to a single address. Often, we want to be able to configure multiple proxies or have more flexible and complex proxy settings. For example, requests to /api/xxx should be proxied to http://192.168.6.8:8080, and requests to /api2/xxx should be proxied to http://192.168.6.8:8082.

Describe the solution you'd like

Configuring multiple and complex proxies with http-server using command-line options can be challenging. We can conveniently achieve this functionality by using a configuration file (such as http-server.json or http-server.config.js).

For example, an http-server.json configuration file might look like this:

{
    "port": 8092,
    "proxy": {
        "/api/": {
            "target": "http://192.168.6.8:8080",
            "changeOrigin": true
        },
        "/api2/": {
            "target": "http://192.168.6.8:8082",
            "changeOrigin": false
        }
    }
}

When http-server runs, it checks for the presence of this default-named configuration file in the current directory. If it exists, http-server reads the configuration and performs the corresponding functions based on the settings.

Activity

changed the title [-]Proxy configuration can be more flex[/-] [+]http-server can be configured with more and more flexible settings, especially regarding proxy functionality[/+] on Nov 8, 2024
changed the title [-]http-server can be configured with more and more flexible settings, especially regarding proxy functionality[/-] [+]http-server can be configured with more flexible settings, especially regarding proxy functionality[/+] on Nov 8, 2024
i3ene

i3ene commented on Nov 14, 2024

@i3ene

It would be nice if the configuration could be specified with --proxy-config <path/to/my-http-config>.json.

github-actions

github-actions commented on May 13, 2025

@github-actions

This issue has been inactive for 180 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JiayangShen@i3ene

        Issue actions

          http-server can be configured with more flexible settings, especially regarding proxy functionality · Issue #906 · http-party/http-server