search

Home  >  Q&A  >  body text

ssh - Apache: How to limit the HOSTs that mod_proxy_connect can proxy to (not visitors, but target servers)?

There is a machine that only opens port 80 to the outside world, and you can use the mod_proxy_connect proxy to access its port 22; but in this case it becomes the ssh service proxy of any server, which is very unsafe. Is there a way to limit it? I can't seem to find it in the official documentation.

曾经蜡笔没有小新曾经蜡笔没有小新2904 days ago719

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 17:07:01

    I modified the code myself to achieve -. -
    apache2.2/modules/proxy/mod_proxy_connect.c +123

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    char *allowed_hosts[] = {

        "some host name",

        "127.0.0.1",

        "localhost"

    }; 

    int hosts_num = sizeof(allowed_hosts) / sizeof(allowed_hosts[0]);

    int k;

    for (k = 0; k < hosts_num; k++) {

        if (strncmp(uri.hostname, allowed_hosts[k], strlen(allowed_hosts[k])) == 0) {

          break;

        }  

     }

    if (k == hosts_num) {

        return ap_proxyerror(r, HTTP_BAD_GATEWAY,

              apr_pstrcat(p, "host not allowed for: ", uri.hostname, NULL));

    }

    reply
    0
  • Cancelreply