Netlify and ngrok linking - ngrok

I have a front-end deployed on Netlify and a back-end is deployed on localhost which is exposed using ngrok.
Is it possible to link them so that when I click on the Netlify link, it would send request to my localhost server exposed from ngrok ?

Netify can proxy to a dynamic backend, that is an intended use case. The problem we'll have is using "localhost" - netlify needs a valid hostname to connect to. So, if your ngrok is exposed (not firewalled) at some public IP, you can put that into your redirects configuration:
/backend-stuff-in-this-path/* https://1.2.3.4/:splat 200!
will send all requests to the path /backend-stuff-in-this-path/ANYTHING to the server at 1.2.3.4/ANYTHING
This may not be incredibly useful since your machine will change IP addresses sometimes one presumes, but if you were using localhost anyway, you weren't planning to put it in production quite yet. Note that redirects are deploy-specific, so you do need to redeploy to change the location if your IP changes.

Related

Pass mixed content with reverse proxy

I have a website and users create their own app. But i can't embed these apps on my website via iframe, because my website has SSL certificate and got this error:
Mixed Content: The page at 'https://domain' was loaded over HTTPS, but requested an insecure resource 'http://IP_ADDR'. This request has been blocked; the content must be served over HTTPS.
My workflow is like that:
Click create button
Deploy EC2 instance from AWS
Get IP EC2 address from AWS
Embed this app via iframe
I want to embed these IPs to my website, IP addresses are dynamic. Anyone can create machine anytime.
What is best practice solution for this issue?
Best practice (and also the only I can think of) solution IMHO would be to use proper HTTPS for the iframe content also. You'd need a possibility to automatically create DNS records though (you can do so with AWS Route 53). Regarding SSL you could use a wildcard certificate (e.g. Let's Encrypt). Nginx could be configured to proxy_pass by DNS name as opposed to IP. Then your workflow would become this:
Click create button
Deploy EC2 instance from AWS
Get IP EC2 address from AWS
Create DNS record
Embed this app via iframe

Url rewriting with Charles Proxy in order to run a wordpress site over a LAN?

I want to use Charles Proxy to share a local development PC's web server where I am developing sites on so that I can access the PC over my LAN to test on various mobile devices.
Having setup the correct ip address of my PC in the http proxy settings on various tablets they can all connect to the PC and this works fine.
The issue is that I need to test a wordpress site and as anyone that uses wordpress knows, it generates full url links between each page it serves. As the site normally runs on my PC the urls it generates are all http://localhost/wordpress/pagename.
So the issue is that if I access the same site from a remote device via the proxy (addressing http://192.168.1.200/wordpress/) it instantly redirects me to http://localhost/wordpress/pagename url in the mobile device and this fails to load as the tablet can't determine "localhost" correctly.
There must be a way of using one of Charles' various options to resolve this but I can't for the life of me work out which. I've tried remote maps and DNS spoofing but no joy.
Note, I'm completely aware that you can with SQL commands change the urls throughout a wordpress database but I just wanted to see if this was possible without undertaking this step as it would be a lot more flexible if I don't have to do that each time I want to preview sites via my other local LAN devics.
You can use Charles proxy feature called Rewrite Tool. I assume your local network uses 192.168.168.X IPs.
Enable rewrite
Add new rule and name it as you wish
To Locations section add Protocol: http and Host: 192.168.168.X
To Rules section add Type: body, Where: response, Match: localhost, Replace: 192.168.168.X
It may require some more tinkering but i hope you get the idea

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.

Google JavaScript API v3 unauthorized on 192.168 connection

I'm working on a project that uses the Google Maps JavaScript API v3 to render directions on an integrated map.
The website it built with Jekyll and I run the server using the following command:
jekyll serve --host 192.168.2.7
The given IP address is the IP Address of the system running the server.
The reason I made it listen to that IP Address is because I want to test the application on my mobile devices, following this answer
In the API Console I whitelisted 192.168.*, so that any local connection can use the API.
However, when I go to that IP Address on my phone or computer, the API says the application is not authorized despite me having whitelisted it.
What am I doing wrong here and how can I solve it?
Jekyll serve
The --hostname flag doesn't exist. Use --host 192.168.2.7 or host: 192.168.2.7 in _config.yml. Target address will then be 192.168.2.7:4000 as 4000 is the default listening port for Jekyll webrick server.
Google API withelist
It's not necessary to white list domain, as with no domain white listed you have Any referer allowed
Google authorization
Verify that you've set your API key to something else than https://maps.googleapis.com/maps/api/js?key=API_KEY you are supposed to have something like this : https://maps.googleapis.com/maps/api/js?key=AIzaSytitittototoX7RhHn-drLRRYututu7eX2hVo
If you still have problems, you can give a repository url to have it fixed quicker.
Happy Jekyll !
192.168.2.7 is a private IP address and is not publicly accessible. To use that you will probably need to get a license.

Proxy + HTTPS = Page doesn't load

I've developed a web app, which uses HTTPS and which works fine when I access is it (live). Yet some customers, who use proxy servers, can't access the site. I already tried to use a real certificate (a cheap one and only a trial, but yet valid), but that didn't help.
Everytime one of these users tries to access the site the browser tries to load it until a timeout occurs. One user even was shown an authentication (but I'm not 100% sure if this was due to a proxy, still waiting for response from the customer)
For which reasons can this happen and what can I do about it?
I'm using IIS, ASP.NET (C#) and JS. Sideinfo: The URL contains a port, the internal structure of the network the IIS is running in (not mine) doesn't allow it otherwise.
443 is dedicated port for HTTPS connectivity. Add type 'HTTPS' with default port 443 in Site bindings of hosted site directory. Check after whether SSL is enabled or not? in IE(browser)->Tools->Internet options->Advanced->Security.
If the HTTPS port in your web app's URL isn't port 443, you'll have a problem with corporate proxies that don't like non-standard HTTPS ports.
i.e. I hope your URL looks something like this: http://example.com:443/...

Resources