Local proxy question - http

Is it possible to install a proxy locally (on Windows XP) and redirect, for example, all traffic from "google.com" to "yahoo.com".
If I call http://www.google.com/test it should redirect it to http://www.yahoo.com/test and return the response from yahoo.
Long story short : I have an old program and there is a URL used in it (for a Web service), but the value of the URL is compiled in the app.
For now, it's connecting in production but I'd like to make some tests in QA, so I would just redirect the URL "http://prod.webservice.website.com" to "http://qa.webservice.website.com" without having to recompile the old application.

Maybe Fiddler will do the job. It's a local proxy that is capable of transforming requests.

You can setup a host file (or edit), if it's just your computer. Would that suffice?

Related

.Net 6 API - can't get data -> ERR_CERT_AUTHORITY_INVALID

I run a .Net 6 API on my Raspberry PI. I can get data from this API using the browser “https://192.168.178.51:7001/swagger/” . Also getting data from entering the url “https://192.168.178.51:7001/api/status/” returns the expected values. So the API is working so far. But when I try to get data from my Blazor WASM App using HTTPClient I get no data. Inspect the browser shows the following message:
GET https://192.168.178.51:7001/api/Status net::ERR_CERT_AUTHORITY_INVALID
How can I fix this? Do I have to install a SSL Certificate? How to do this for a self contained API?
You will need, at minima, a self-sign certificate. Then you will need to let your browser accept a self-sign.(Advance, Proceed to ServerIp)
Now, I do not know what OS you are using in your Raspberry, but for a Beaglebone(similar to Raspberry Pi) with Debian and nginx, here is the procedure
https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-on-debian-10
You will need the same kind of steps for which ever OS and webserver(Apache, nginx...Kestrel?).
Using a reverse proxy will be the solution, as described here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-6.0
Quote from the article:
Kestrel is great for serving dynamic content from ASP.NET Core. However, the web serving capabilities aren't as feature rich as servers such as IIS, Apache, or Nginx. A reverse proxy server can offload work such as serving static content, caching requests, compressing requests, and HTTPS termination from the HTTP server.
Using a reverse proxy I can set a certificate.

ngrok - Get all routes to localhost server

I'm using ngrok (free account) in my localhost for my coded web server written in Go
In Ubuntu, after starting my server (which listens on port 3000), I run this command to start ngrok:
./ngrok http 3000
Then other PC can get access to my demo web by path provided by ngrok, for instance, http://6fed323a.ngrok.io
But when they do something on it (for example, click on a button that redirects), the host of URL becomes localhost again
There isn't any functions of ngrok that allows access to all routes in server, is there? I'm learning
I just ran into this issue, the reason for this is because your button uses a straight absolute path redirect which ngrok (or any tunneling service ive used so far) cannot handle. You need to use a relative path redirect such as:
window.location.href = '/path';
In general, it is considered best practice to always use relative urls so that the app is not bound to the hostname. Of course, this is in an ideal work- most legacy apps may not follow this unfortunately.
While I was working on a Rails app I wanted to run it on ngrok but I got error below:
The connection to http://xxxxxx.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:3000.
It seems like ngrok works fine but my local server is not. Which is true since I forgot to run my rails app first by run $ rails s. By doing so I was able to get ngrok tunneing works fine.
Make sure your local server run first.
I have noticed ngrok url changes to localhost url when I click on site logo which is defined as root_path in my route file. But other links and header tabs for example works fine and shows ngrok url.
Good luck.

Windows Azure VM SSL and Cloudapp.net

I installed an ASP.net application on a windows Azure VM (IIS 7). SSL certificate is installed, configured and the application works correctly. I have removed Http binding and http endpoints.
The issue I am having is that if I use the cloudapp.net link (using https), the application still opens with a mismatched certificate.
What can I do to deny any user from opening my application using https://xx.cloudapp.net/x?
It seems really silly that people are saying this isn't the right place for this question, since some of the solutions could be code related. ie: In your application, check the host and if it's cloudapp.net, do a URL redirect.
There's a few different options here but it sounds like what you're looking for is just the ability to prevent someone from viewing the application using that URL.
What I would do is set up a site in IIS that uses Host Header resolution to look for xx.cloudapp.net. If that URL is recognized, do a redirect using the HTTP redirect settings to the https version of your app. Don't bind the SSL port to this site or you'll run into SSL errors like you showed above.
The other option is to leave it out entirely and simply use the Host Header resolution to filter out requests for your site. I suspect what you've done is assign all incoming requests to the only IP address on the system, which is why the xx.cloudapp.net is showing your app and the cert is failing.
This would cause xx.cloudapp.net to fail to show any site at all but I think that might be what you want to do anyway.

Test multiple domains using ASP.NET development server

I am developing a single web application that will dynamically change its content depending on which domain name is used to reach the site. Multiple domains will point to the same application. I wish to use the following code (or something close) to detect the domain name and perform the customizations:
string theDomainName = Request.Url.Host;
switch (theDomainName)
{
case "www.clientone.com":
// do stuff
break;
case "www.clienttwo.com":
// do other stuff
break;
}
I would like to test the functionality of the above using the ASP.NET development server. I created mappings in the local HOSTS file to map www.clientone.com to 127.0.0.1, and www.clienttwo.com to 127.0.0.1. I then browse to the application with the browser using www.clinetone.com (etc).
When I try to test this code using the ASP.net development server the URL always says localhost. It does NOT capture the host entered in the browser, only localhost.
Is there a way to test the URL detection functionality using the development server?
Thanks.
Figured this one out on my own. The problem here wasn't that the HOSTS file didn't work, it was that I was using the wrong method to detect the host header from the browser.
This does NOT work, and only repeats the 127.0.0.1 localhost that the ASP development server lives on.
Request.Url.Host;
However, by using the following instead, the domain entered into the browser is stored and can be used to dynamically change the site behavior, even on the ASP development server.
HttpContext.Current.Request.Headers.Get("Host").ToString();
So the solution to test multiple domains on a Dev server is:
create several test domains in the HOSTS file on your local machine pointing to 127.0.0.1
use the Headers.Get("Host") syntax to sniff the domain entered into the browser
The only 'gotcha' that I found is that you must still manually preserve the specific port that the ASP dev server is running on.
Example:
if you have in your hosts file www.mytestdomain.com pointing to 127.0.0.1, and your dev server is running on port 46146, then you must enter the following into your browser for testing: http://www.mytestdomain.com:46146/
But it still works!

Creating a HTTP handler for IIS that transparently forwards request to different port?

I have a public web server with the following software installed:
IIS7 on port 80
Subversion over apache on port 81
TeamCity over apache on port 82
Unfortunately, both Subversion and TeamCity comes with their own web server installations, and they work flawlessly, so I don't really want to try to move them all to run under IIS, if that is even possible.
However, I was looking at IIS and I noticed the HTTP redirect part, and I was wondering...
Would it be possible for me to create a HTTP handler, and install it on a sub-domain under IIS7, so that all requests to, say, http://svn.vkarlsen.no/anything/here is passed to my HTTP handler, which then subsequently creates a request to http://localhost:81/anything/here, retrieves the data, and passes it on to the original requestee?
In other words, I would like IIS to handle transparent forwards to port 81 and 82, without using the redirection features. For instance, Subversion doesn't like HTTP redirect and just says that the repository has been moved, and I need to relocate my working copy. That's not what I want.
If anyone thinks this can be done, does anyone have any links to topics I need to read up on? I think I can manage the actual request parts, even with authentication, but I have no idea how to create a HTTP handler.
Also bear in mind that I need to handle sub-paths and documents beneath the top-level domain, so http://svn.vkarlsen.no/whatever/here needs to be handled by a single handler, I cannot create copies of the handler for all sub-directories since paths are created from time to time.
Try the Application Request Routing addon for IIS to configure IIS as a reverse proxy.

Resources