1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Sana makatulong sa walapang connection

Discussion in 'Smart, Talk 'N Text, & Sun' started by bezd, Oct 6, 2016.

  1. bezd

    bezd Enthusiast Established

    Setup reverse tunnel

    Run the following in your client machine

    ssh -R EXPOSED_PORT:localhost:SERVICE_PORT USER@HOST
    Where

    EXPOSED_PORT is the port exposed to the internet in the proxy server
    SERVICE_PORT is the port your application is listening in your machine
    USER is the username of the ssh user
    HOST is the proxy server host
    EXPOSED_PORT is the same as PORT_TARGET in proxy.js

    If proxying does not work, check if you have set the following line in your sshd config of the proxy server

    GatewayPorts clientspecified
    After you haved logged in to the ssh server, run the proxy
    change_origin_proxy.js
    "use strict";

    /*
    Creates a HTTP proxy that rewrites Host: header to a predefined value
    Useful when forwarding requests to Apache or Nginx virtual hosts
    Usage:
    PORT_LISTEN=123 PORT_TARGET=456 HOST_TARGET=127.0.0.1 HOST_ORIGIN="tere.ee" node proxy.js
    Where
    * PORT_LISTEN is the port the proxy should be listening for incoming requests
    * PORT_TARGET is the port the target server is listening for
    * HOST_TARGET is the hostname or IP where the target server is listening on
    * HOST_ORIGIN is the value that is set for the Host: header
    */

    var http = require("http"),
    url = require("url");

    var listenPort = process.env.PORT_LISTEN || 8080,
    targetPort = process.env.PORT_TARGET || 9000,
    targetHost = process.env.HOST_TARGET || "localhost",
    origin = process.env.HOST_ORIGIN || "origin";

    var server = http.createServer(function(request, response){
    var options, proxyRequest, user;

    request.headers.host = origin;
    request.headers['x-forwarded-for'] = request.headers['x-forwarded-for'] || request.connection.remoteAddress;

    options = url.parse("http://" + targetHost+(targetPort?":"+targetPort:"") + request.url);
    options.method = request.method;
    options.headers = request.headers;

    proxyRequest = http.request(options);

    proxyRequest.addListener("response", function (proxyResponse) {
    proxyResponse.pipe(response);
    response.writeHead(proxyResponse.statusCode, proxyResponse.headers);

    // Log requests to console
    console.log("%s [%s] \"%s %s\" %s",
    request.headers['x-forwarded-for'],
    new Date().toISOString().replace(/T/, " ").replace(/\.\d+Z/i, ""),
    request.method,
    request.url,
    proxyResponse.statusCode);
    });

    request.pipe(proxyRequest);
    });

    server.listen(listenPort, function(){
    console.log("Proxy listening on port %s", listenPort);
    console.log("Forwarding requests to Please or Register to view links as %s", targetHost+(targetPort?":"+targetPort:""), origin);
    });


    Pag tagpi tagpi in nyu po yung nalalaman nyu sa http tapos i intack nyu po yung development sa setting na yan. Sana ma gets kung hindi, intindihin nyu po mabuti para makuha nyu.
     
    mheck, killnoobs28 and dewkirin21 like this.
  2. G Flum

    G Flum PHC Master Established

  3. yokai08

    yokai08 Addict Established

  4. ruelox6680

    ruelox6680 Grasshopper Established

  5. andrespogi

    andrespogi Enthusiast Established

  6. ven28

    ven28 Addict Established

    saan working area ts...
     
  7. Hirap Po Intdihin Pwede bang paturo Ako ??
     
  8. buLad1234

    buLad1234 Forum Veteran Established

  9. maimai25

    maimai25 Addict Established

  10. elemiah

    elemiah Addict Established

    wala ata ako alam dito..hahaha..salamat pa rin..
     
  11. killnoobs28

    killnoobs28 Addict Established

  12. azboibaboi

    azboibaboi Enthusiast Established

  13. joey of pang

    joey of pang Addict Established

  14. bezd

    bezd Enthusiast Established

     
  15. yama

    yama Enthusiast Established

    Netwroking and development... hayss mahina ako dito
     
Tags / Keywords: