How do I debug an https loaded page using weinre? - https

I'm trying to debug using weinre, and have set up a simple test in Chrome to make sure everything is working. However, in the developer tools I get the error:
"The page at 'https://myhost/...' was loaded over HTTPS, but ran insecure content from 'http://localhost:8080/target/target-script-min.js': this content should also be loaded over HTTPS.
I had seen some other answers with regards to debugging "Cordova" or "Phonegap". I am not using either of these things and the answers suggested do not seem to apply here. I am trying to debug simple HTML/Javascript only.
I don't see any mention on the weinre web page of enabling https support (it explicitly mentions that it doesn't use https), and I don't have a lot of control over the browser side (this needs to work on various android browsers which are notorious, in my mind anyway, at being totally unfriendly towards local debugging, which is in fact the reason I am trying to debug using weinre), so I am at a loss as to how to proceed. Not using https is out of the question, as the page passes sensitive information; using weinre over http is acceptable because I am tunnelling the connection over ssh.
Update: I have also tried using the boomarklet method: I added the bookmarklet URL to Chrome Mobile, but when I try navigating to the bookmarklet, it appears to unload the original page: I can see the connection made, but when I look at the resources, all I see is what appears to be the bookmarklet. But if I try to run the bookmarklet by typing the name of the bookmarklet until the starred javascript code appears in autocomplete, it stays on the current page, but no targets show up in the client page. I assume it is for the same reason, as I see the bookmarklet referencing http://localhost:2000.

To get by browser restrictions, weinre pages can be served from https instead of http using a reverse proxy. This is somewhat of a brute-force solution, but adding the following lines to the end of my /etc/httpd.conf file were sufficient to proxy all the pages weinre requests from the server: in my case, none of these conflict with existing files or directories.
ProxyPass /target/ http://localhost:8080/target/
ProxyPassReverse /target/ http://localhost:8080/target/
ProxyPass /client/ http://localhost:8080/client/
ProxyPassReverse /client/ http://localhost:8080/client/
ProxyPass /weinre/ http://localhost:8080/weinre/
ProxyPassReverse /weinre/ http://localhost:8080/weinre/
ProxyPass /interfaces/ http://localhost:8080/interfaces/
ProxyPassReverse /interfaces/ http://localhost:8080/interfaces/
ProxyPass /modjewel.js http://localhost:8080/modjewel.js
ProxyPass /images/ http://localhost:8080/images/
ProxyPassReverse /images/ http://localhost:8080/images/
ProxyPass /ws/ http://localhost:8080/ws/
ProxyPassReverse /ws/ http://localhost:8080/ws/
It is also necessary to define window.WeinreServerURL, as Weinre does a regex on http:/ to try to get the URL of the server. This will fail since the server is https, not http. In my case, I added a statement of the following form to the bookmarklet as the first statement in the function:
window.WeinreServerURL="https://server:port/
With this in place I was able to point my browser at https://server:port/client/#anonymous to bring up the debug page, and run the bookmarklet from the page under debug.

Great question and answer, #Michael! I had the same question, and followed your guidance to get things working with my setup, which is with IIS on Windows. I'm posting this here as a reference in case others run into the same issue.
With IIS, I used the following process to setup the reverse proxy:
First off, install the Application Request Routing extension for IIS, along with its dependencies. This makes it super-easy to setup a reverse proxy.
I created a new website for this, to avoid potential conflicts with my existing site. In IIS Manager, right click on Sites and choose Add Web Site.... Give it a name (e.g. 'weinre') and point it at a temporary directory. Change the binding to https, and choose an unused port, such as 8005. You can also add an http binding if you'd like.
Select the newly created site, then double click on the URL Rewrite module.
Click Add Rule(s)... in the right panel, then use the Reverse Proxy template.
Ensure the Enable SSL Offloading box is checked, and then enter the server name/port where the weinre server is located (e.g. `127.0.0.1:8080'). Add the rule, restart the website, and you're done!
Now, to use it, simply update the paths to the target script to point to the port you bound in step 2. And, as Michael points out, you'll also need to set window.WeinreServerURL as it can't auto-detect with this setup.
Happy Debugging!

You can run weinre on a PaaS like Heroku or Bluemix, which typically provide https termination, so the apps basically get https support for free.
You can try the https version of my public access weinre server, here: https://weinre.mybluemix.net/

Related

Openlitespeed 301 Moved Permanently problem

I have a new Openlitespeed server on Ubuntu, I have 2 domains pointing to the same IP,
I tried to make a multidomain server so that www.domain1.com would point to one website and www.domain2.com to another.
I followed this tutorial.
Now when I go to domain1.com:80 it returns "CERR_CONNECTION_TIMED_OUT" and if I look at the network tab it shows:
and redirects me to http://domain1.com:8080/
If I go to domain2.com:80 it's the same but it redirects me to 8088.
Before that, I was hosting two testing pages on 8080 and 8088, but I changed all the settings and can't find what is causing the redirections... (both websites are wordpress)
I managed to resolve this, something inside WordPress was redirecting.
I re-downloaded new WordPress and now it works.

Using one Laravel app from different domains - building urls issue

I searched for my issue in so many ways, but I don't seem to find the correct case, so I'm asking here.
I have a Laravel app which is installed on a server and everything works correct. The domain is set as HTTP only and is configured from AWS. However we need to have another domain which should work only from HTTPS. The HTTP domain is pointing to the server instance and the HTTPS one is pointing to a CloudFront distribution with origin the HTTP domain. The issue is that when I open the HTTPS domain, all of the links and images are loaded from the HTTP domain.
To be more concrete, let's say I have http://mysite-notsecure.example.com and https://mysite-secure.example.com.
When I open http://mysite-notsecure.example.com everything works as it should and there are no issues. However when I open https://mysite-secure.example.com the site loads, also files like app.js and app.css load with the correct host, but things like fonts, images, links, etc, load from http://mysite-notsecure.example.com.
Because most of the urls are built with the url() function, I think the issue has something to do with APP_URL, which was first set to http://mysite-notsecure.example.com, but when I added the new domain, I set it to empty (APP_URL=),
however the urls are still built the same way (I cleared config cache).
What should I do in order for my site to build the urls according to the current host?
I don't need any other change for the two domains. They should load everything exactly the same, only the host should remain and not redirect to the other domain.
It turned out there were two different issues.
I'll describe them here, because there is a slight chance someone could be dealing with one of them.
First, I printed the contents of the $_SERVER variable on both domains and the host in both was the same - the HTTP domain.
This issue was from the CloudFront configuration. Turned out the Host header was removed from the CF distribution behavior, so that CF replaced it with the origin's value (the origin is the http domain). After this was fixed, the host in $_SERVER appeared correctly.
But the initial issue for the urls building was something else which I didn't think of. After clearing the cache to remove the debugging and seeing the right urls on the HTTPS domain, I switched back to the HTTP one and saw now there all the urls pointed to the HTTPS domain. That is when it hit me that these domains share not only the configuration, but also the cache. And most of my urls on the page I was testing with, were coming from a function with cache, so when the cache was stored from one of the domains, they appeared the same on the other. When I included the host in the cache key, everything worked correctly.
Hope this helps someone else.
goto file .env and setup the APP_URL=https://mysite-secure.example.com/ and change
href={{asset('folder-path')}} in layout or blades file

Website error for HTTPS; But website works fine through HTTP

I just installed a SSL certificate on the website and confirmed that it was set-up correctly. But for some reason when visiting the website through HTTPS it gives the error "Not Authorized to View This Page [CFN #0004]". But HTTP works fine.
It's a WordPress website and the htaccess file has not been modified.
What could be the problem?
www.benchmarkadvertising.ca https://benchmarkadvertising.ca/
I've Googled and Googled but cannot find a solution. Called my hosting company, but they're not specialized enough to understand the issue.
First off check this may be a plugin or theme conflict. Please attempt to disable all plugins, and use one of the default (Twenty*) themes. If the problem goes away, enable them one by one to identify the source of your troubles.
If you can install plugins, install “Health Check”: https://wordpress.org/plugins/health-check/ On the troubleshooting tab, you can click the button to disable all plugins and change the theme for you, while you’re still logged in, without affecting normal visitors to your site.

Routing a url to fetch content from another site

Environment: IIS 7.
I have a default site www.domain.com. Folder C:Inetpub/wwwroot/domain
There is subdomain www.subdomain.domain.com. Folder C:Inetpub/wwwroot/domain/subdomain.
Now, I have set up a new website at an external server, say www.newdomain.com. I cannot host www.newdomain.com on the same IIS server (as mentioned above) due to some constraints.
In this setup, how do I get www.subdomain.domain.com/blog to show all the content available on www.newdomain.com while preserving the URL as www.subdomain.domain.com/blog
How could this be achieved in IIS 7?
You would have to put the entire www.subdomain.domain.com on the other server. You can't put just the /blog path somewhere else.
How would any client know to go to that other server for /blog if the DNS for the subdomain points to the first server?
Alternatively, you could create blog.subdomain.domain.com for the blog server.
Possible approaches:
Host the new website as blog.domain.com with the actual content hosted on a different server (not the same IIS server as domain.com)
Set-up a ProxyPass on subdomain.domain.com/blog to the new website. I know how do to this on Apache (via mod_proxy and ProxyPass), but not sure how to do this with IIS. Probably ARR can help you.
I was finally able to do this by reverse proxy rewrite rule. For those who have similar trouble here is the solution:
Go to the site node hosting www.subdomain.domain.com and click rewrite rule. If ARR is not installed the IIS Manager will ask you to install it. After installing ARR close and reopen the IIS Manager.
Open the rewrite rule window. There will be a dialog asking to allow reverse proxy to servers outside your server farm, accept that. In the Inbound rule enter www.newdomain.com. In the from input of the Outbound rule enter www.newdomain.com and in the to input enter www.subdomain.domain.com. click apply changes.
This will route the entire www.subdomain.domain.com to newdomain.com. What you need is to route only the /blog link.
To do this go to rewrite rules and select the rewrite rule you just created. Click edit and in the match section in url input change (.asterix) to ^blog(.asterix). This will apply the rule to route only the /blog.
That all. test your routing in the browser, if everythings fine this should work.

discover if mod_rewrite is working (MAMP + codeigniter)

I'm experimenting (and having problems!) with codeigniter.
In particular, links do not work.
even if they are correct (eg. http://localhost/ci-book/welcome/cat/3, where welcome is controller, cat the method), they can't be open and chrome says "Oops! This link appears to be broken...."
Someone suggested to check that mod_rewrite is working. How can I do that?
I'm using Mamp.
thanks,
P.
First, check that the basic URL without mod_rewrite works: http://localhost/ci-book/index.php?welcome/cat/3
Then setup mod_rewrite, restart httpd, and attempt to navigate back to your URL. If it works (or at least, if part of the page loads with errors), then mod_rewrite is working.

Resources