How to proxy https XHR requests to another host? - proxy

I have a website that is running online. I do not have the source code to the UI 's HTML, CSS and JS ( Example: https://online-page.com/ )
I have the source code for backend web APIs of that same website, hosted locally for local development ( http://localhost:3333/ )
I would like to "proxy" some request from the running online UI to my local development API for easier development
https://online-page.com/some/sub/api/path/ -> Proxy Server? -> http://localhost:3333/path
Currently I am using Fiddler and while it is possible to intercept everthing and write custom rules, modify host headers... etc etc, It just seems too clunky. Is there any solution out of the box that support this kind of use-case?

Related

HTTPLibrary.HTTP's GET call to a URL from Robot Framework timing out

I am using HTTPLibrary.HTTP's GET call to a URL from Robot Framework. This keeps timing out. I think it is a proxy issue (I want this to work on my company's intranet). Is there a way to configure proxies for this call (A company internal website opens up just fine)? Or some other libraries I could use?
Code:
Library HttpLibrary.HTTP
*** Test Cases ***
Test1
GET http://www.thomas-bayer.com/sqlrest/ #example wesbite
Thanks,
srivikas
You can try out robotframework-requests that provides an example with a proxy in its README. Here is an excerpt:
${proxies}= Create Dictionary http=http://acme.com:912 https=http://acme.com:913 |
Create Session github http://api.github.com proxies=${proxies}
${resp}= Get Request google
Should Be Equal As Strings ${resp.status_code} 200

node-webkit equivalent for sinatra?

I've been thinking about learning how to make simple Mac OS X applications based on web-technology and I came across node-webkit which seems compelling. However, I've recently invested in learning the basics of Sinatra/Ruby and I wanted to stay on that course.
Is there a "node-webkit equivalent" for developers who use Sinatra? Or, is there a recommended way to use the Sinatra framework (or Ruby) to build OS X apps that are essentially web wrappers?
Sinatra is a server-side framework.
Contrary to Node-webkit which is on client side.
If you need to interact with a server, you can still use sinatra (as well as node.js, php, ...) on your server.
But if you are looking for a framework like sinatra on node.js, you should look into Express.js : https://npmjs.org/package/express
Node-webkit can use file or http, and which to use depends on your needs. The majority of the time you shouldn't need to, Node-webkit runs completely client-side using only HTML, javascript, and css. You certainly can initialize a local webserver when Node-webkit loads, but first try making a basic "Hello World" application to learn how it works.
If you still think you need to spin up a web server, then the code might look something like this (I'm using Express.js):
// Retrieve libraries...
var expressPort = 6014
var NodeWebkit = require('nw.gui');
// Call focus to application...
NodeWebkit.Window.get().focus();
// Instantiate the Express Server...
var spawn = require("child_process").spawn;
spawn("node", ['./server/server', expressPort]);
// Request director page...
window.location.replace('http://localhost:'+expressPort);
In order to use the Node-webkit features from a page on localhost you will also need to add the following line beneath the root of your package.json:
node-remote": "<local>
Note: While this does work, you must really consider whether it makes sense. In other words, is you application fully self-contained? If nothing will access that content except the application then you don't need it.
For my application I am using Node-webkit as an admin console for creating/managing broadcasts. (hence the local webserver)
Nw is not a web framework. Nw does not use a http protocol; it does use a file protocol.
Nw is composed of chromium and nodejs, which allows you to run both DOM and node.js stuff -- without setting up a web server.

Add site bindings to IIS 7.5 programmatically

I have a web application that requires multiple domains to point to the same site in IIS. I would like to be able to do this from a web interface but that would mean adding site bindings programmatically.
Im sure applications like Plesk access some sort of Windows API to do it, I just dont know how.
A related post is this one but it doesnt solve this specific problem.
I'm not sure if this is what you're after, but if you are using .NET you can use ServerManager class from the Microsoft.Web.Administration namespace you can add bindings like so:
using (ServerManager manager = ServerManager.OpenRemote("serverName"))
{
manager.Sites["mySiteName"].Bindings.Add("*:80:domain.com", "http");
manager.CommitChanges();
}
So in the example above the * means the IP to match to, 80 is the port, and domain.com is the host header. To add https bindings is a bit more involved and you need to load the certificate programatically.

Custom RequireHttps and testing

I have a custom Authorize attribute. This attribute checks if the user also have permissions to that action based on the parameters of the attribute. In some times inside the custom Authorize attribute I want to requiere HTTPS or redirect to it. Is there any way to do this with the AuthorizationContext?
How can I test it? and debug it? Is there a simple tutorial to use SSL in my developer machine with VS 2010?
Thanks!
RequireHttps will redirect HOWEVER it doesn't stop the browser from sending data non-ssl first which could be captured. Note that for post actions this wont work right out of the box either.
To install ssl, simply generate your cert and import it. Do you have a subscription to pluralsight.com? i have a course up there where I go over the steps for requiressl and installing ssl on local machine (theres a 30 day free trial too)
If you just want the details here : )
theres a nice powershell script to use:
http://learn.iis.net/page.aspx/491/powershell-snap-in-configuring-ssl-with-the-iis-powershell-snap-in/

Accessing a file in another server from GWT Client side

I have a file, sample.xml located at one web server. I want to access this file from a GWT application running at another server. I dont want to make RPC calls to the same server serving GWT application and access the required file on server side (like a proxy). I want to access the file directly from client side as my application is going to be hosted as static files in a web server.
Is there a way to do that?
Sure - you must issue a XHR (XmlHTTPRequest) from the browser, and then parse the data.
In GWT you can do it using the RequestBuilder class (see here).
Please note that some client side restrictions may apply (e.g. Single Origin Policy etc.)
You issue the request (GET or POST - GET in your case) and pass a callback instance.
The instance's onResponseReceived method receives a Response object, which by calling its getText method returns the received contents.
You're trying to have your website (a.com/index.html) reference b.com/sample.xml. I see a few options.
If you have access to b.com's servers:
Edit sample.xml into sample.js to contain the same information in JSON with a callback, and reference it with a script tag
Compile your website using the cross-site loader (see Controlling Compiler Output), put your index.html at b.com/index.html, put all the rest of your files on a.com. Then all your RPC calls can go to b.com, but this means the user would have to navigate to b.com instead of a.com
If you don't have access to b.com's servers:
- Simply provide a link for people to download sample.xml
- Host a.com on a server with some kind of script support (PHP, Python, Ruby, Java, anything) and put a proxy to b.com/sample.xml

Resources