Using Google App Engine to Initiate Messages to a Device Behind Firewall

帅比萌擦擦* 提交于 2019-12-06 03:43:15

Since the secure data connector is deprecated, your best option is to deploy a service that will proxy the incoming requests. You have a number of options like configuring your firewall and setup port forwarding or apache reverse proxy.

If your internal addresses change, then that is also the place to deal with this. For instance, you could let the DHCP server trigger a configuration change in your apache reverse proxy.

For future searchers, to follow up on koma's response here is the config for an nginx combination reverse proxy and forward proxy that should do the trick. The devices send all their traffic to it on port 80 which gets reverse proxied to App Engine. Oppositely App Engine sends requests to the firewalled devices using the forward proxy on port 8080 so that all GAE traffic appears to come from the same IP. The remote ip and remote port are added as headers of the proxied requests.

worker_processes  2;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       8080;

        location / {
            resolver 8.8.8.8;
            proxy_pass http://$http_host$uri$is_args$args;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    server {
       listen      80;

       location / {
            proxy_pass  http://something.appspot.com;
            proxy_redirect off;
            proxy_buffering off;
            proxy_set_header        Host            something.appspot.com;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Real-Port     $remote_port;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!