I want to pass some external URL to localhost with all their parameters (such as GET, POST, etc) while other URLs of these hosts be untouched.
for example:
example.com/path-to-file/server.php?params => localhost/server.php?params
But:
example.com/path-to-file/other.php?params => example.com/path-to-file/other.php?params (Direct routing)
Add your host entry in the following file:
%systemroot%\system32\drivers\etc\
Make sure you edit the file as administrator.
You could then start a simple web server listening to requests and pass them to the original url only if they contain the parameters (i.e. file name) you want.
I understand that Fiddler proxy server supports custom HTTP header variables. I'm new at this, my goal is to simulate a passed custom variable the way an F5 appliance would pass an HTTP header variable (string) for a web app. The variable string is used to authenticate the user. I do not have access to a load balancing appliance and have to find a way to simualte or manually add it.
Will apreciate any input on how to accomplish this...
You can add your own header variables to the OnBeforeRequest function (or OnBeforeResponse) within CustomRules.js, such as the following:
oSession.oRequest["NewHeaderName"] = "New header value";
More info: http://fiddler2.com/documentation/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse
I need proxy ip address of Opera Mini to use it in Geo module (nginx). Nginx can automatically use X-FORWARDED-FOR header for proxies, but where to get proxy list?
Not sure I understand exactly what problem you want to solve, but I assume you want to implement some geolocation feature for the end-user and your question is about what IP address to use.
If so, please see the documentation for Opera Mini request headers and X-Forwarded-For:
http://dev.opera.com/articles/view/opera-mini-request-headers/
X-Forwarded-For
This contains a comma-separated list of the proxy servers the request has passed on its way from the device to the Mini proxy. The first item in the list that is not an internal IP will always be the IP address that connects to the Mini proxy, hence it is the most reliable source of information about the origin of the request, and is suitable for geolocation etc.
Cannot find the official list anywhere on opera website. Here is some of those ips
[EDIT] Removed one paragraph of my original answer here, because that could be misleading. After reading the nginx GeoIP source code, it seems necessary to know all of the 'trusted' opera mini proxies such that nginx GeoIP module can get an IP behind those proxies using x-forwarded-for header.
Are you sure that Opera IP addresses are not already in MaxMind database? (that's the DB that the nginx module uses by default)
My first bet would be to think that those IP addresses are going to be in MaxMind list, being proxies or not.
But I think that the best thing to do is a quick test using opera proxies and another proxies from any public HTTP proxy list resource. Then verify if you're getting the geo location of your proxy IP or not.
Remember to configure Nginx to use the x-forwarded-for IP for the geo location.
real_ip_header X-Forwarded-For;
Then a simple example for testing could be:
<html>
<head>
<title>What is my IP address - determine or retrieve my IP address</title>
</head>
<body>
<?php
if (getenv(HTTP_X_FORWARDED_FOR)) {
$pipaddress = getenv(HTTP_X_FORWARDED_FOR);
$ipaddress = getenv(REMOTE_ADDR);
echo "Your Proxy IP address is : ".$pipaddress. " (via $ipaddress) " ;
} else {
$ipaddress = getenv(REMOTE_ADDR);
echo "Your IP address is : $ipaddress";
}
$country = getenv(GEOIP_COUNTRY_NAME);
$country_code = getenv(GEOIP_COUNTRY_CODE);
echo "<br/>Your country : $country ( $country_code ) ";
?>
</body>
</html>
(I just copy/paste that example from another site but I think that's well done)
Proxy (but really MITM) servers for Opera Mini and Opera Turbo reside in "Opera Software AS" IP address blocks, which include:
37.228.104.0 255.255.248.0
82.145.208.0 255.255.240.0
107.167.96.0 255.255.224.0
141.0.8.0 255.255.248.0
185.26.180.0 255.255.252.0
I need to redirect anyone with a mobile user agent to a file called mobile.php.
My web hosting provider, Net Registry uses the Zeus web server.
Here's the script I've written from my research
RULE_1_START:
# get the document root
map path into SCRATCH:DOCROOT from /
match IN:User-Agent into $ with iPad|iPod|iPhone|Android|s+Mobile
if matched then
set OUT:Location = /mobile.php
endif
RULE_1_END:
I used the instructions on my host's site.
I pasted that into their console and it has worked to do redirects. Net registry have some odd console thing that you submit and it takes 10 minutes to update the zeus server config (annoying as hell).
Anyway my issue is that it redirects me to the wrong location:
So if you visit the site, with a user agent string that contains ipad|ipod|android|\s+mobile then you will trigger it ()
It takes me here:
http://example.com.au/mobile.php,%20catalog/index.php
I can't work out how to fix that, or why that happens because at the moment this file exists:
http://example.com.au/mobile.php
as does this one:
http://example.com.au/index.php. Contents of this file are:
<?php header("Location: catalog/index.php");
Any ideas on how I can make this work more like an apache .htaccess url Rewrite?
the official Zeus documentation
Fixed it by changing
set OUT:Location = /mobile.php
to
set URL = /mobile.php
From the manual...
Using Request Rewrite Scripts
To use the request rewriting functionality, create a script in the Zeus Request
Rewrite Scripting Language. The script contains instructions telling the
Virtual Server how to change the URL or headers of requests that match specified criteria.
The Virtual Server compiles the script, and (if the rewrite functionality is
enabled) uses it every time it receives a request. It runs the commands in the
script, changing the URL if it matches the specified criteria. Once the script is
finished, the Virtual Server continues processing the resulting URL.Zeus Web Server 4.3 User Guide
142 Configuring URL Handling
When changing the URL, the rewrite functionality can only change the local
part of it, that is, the part of the URL after the host name. For example, if a
user requests http://www.myhost.com/sales/uk.html, the rewrite
functionality can only make changes to /sales/uk.html. This means that
you cannot use the rewrite functionality to change the request to refer to a
file on another Virtual Server.
For example, the following script illustrates how to change requests for any
HTML files in the /sales directory so that the user receives them from the
/newsales directory instead:
match URL into $ with ^/sales/(.).html
if matched set URL=/newsales/$1.html
The rewrite functionality can also change the HTTP headers that were received
with a request, and create new HTTP headers to be returned to the user. For
example, the following script changes the HTTP host header, so that a request
for www.mysite.com/subserver is redirected to the Subserver
www.subserver.mysite.com:
match URL into $ with ^/([^/]+)/(.)$
if matched then
set IN:Host = www.$1.mysite.com
set URL = /$2
endif
My computers are sitting behind a router/firewall. How do I programmatically find out what my external IP address is. I can use http://www.whatsmyip.org/ for ad-hoc queries, but the TOS don't allow for automated checks.
Any ideas?
http://ipecho.net/plain appears to be a
workable alternative, as whatismyip.com now requires membership for
their automated link. They very kindly appear to be
offering this service for free,
so please don't abuse it.
Unfortunately there is no easy way to do it.
I would use a site like www.whatsmyip.org and parse the output.
checkip.dyndns.com returns a very simple HTML file which looks like this:
<html>
<head>
<title>Current IP Check</title>
</head>
<body>
Current IP Address: 84.151.156.163
</body>
</html>
This should be very easy to parse.
Moreover the site is exists for about ten years.
There is hope that it will be around for a while.
If you have access to a webserver with modphp, you can roll your own:
<?php print $_SERVER['REMOTE_ADDR']; ?>
If you don't want that to get abused, you'll have to keep it secret or add request limits.
I've been using one on my server for years.
Explicitly:
Create a file called whatismyip.php in your public_html folder in your website. It can be called anything and be anywhere in your webroot.
Add the line above, and then query your server:
curl http://example.com/whatismyip.php
for example.
Unfortunately as of 2013, whatismyip.com charge for the service.
http://www.icanhazip.com is still going strong, 3 years later. Just outputs the IP as text, absolutely nothing else.
http://checkip.dyndns.org still works as well.
You can also use Google if you want to be sure it won't go down, but it can still block you for TOS violations.
https://www.google.ie/search?q=whats+is+my+ip
But even when they block me, they still tell me my client IP address in the error message.
curl ifconfig.me
or
curl ifconfig.me/ip
Incase you don't have curl installed,
wget ifconfig.me/ip 2>/dev/null && cat ip
Hope this helps.
If the router you are behind speak UPnP you could always use a UPnP library for whatever language you are developing in to query the router for its external ip.
http://myexternalip.com provides this kind of information. To
retrieve your IP you have plenty of options:
http://myexternalip.com/ - browser + lot's of examples of how to use it
http://myexternalip.com/raw - a pure text answer, only your ip, no other crap
http://myexternalip.com/json - a resposnse ready for json-parsers, also supports jsonp
HEAD http://myexternalip.com - send only a HEAD-request and get the answer
Since this question was asked a while back, there's now a freely available web service designed specifically to allow you to determine your IP address programmatically, called ipify.
$ curl 'https://api.ipify.org?format=json'
Results in
{"ip": "1.2.3.4" /* your public IP */}
Another way is if you have access to a cloud email (yahoo, google, hotmail), send yourself an email. Then view the headers and you should see your IP address in there.
I would look up the exact area but the headers may vary from each implmentation, Look for the received-by and follow that until you get to something that looks like sent-by
EDIT: This answers the how to find IP address, not the via PROGRAMMATIC approach
My WRT54G router tells me through its Local Router Access feature (the http(s) administration interface), and I imagine something similar could be done with many other devices. In this case, the entry page gives the octets of the IPv4 address in four lines containing this phrase:
class=num maxLength=3 size=3 value='i' name='wan_ipaddr_N' id='wan_ipaddr_N'
Where i is the octet value and N is the octet number. This bit of doggerel fetches and parses it for me, courtesy of cygwin:
#! /usr/bin/env perl
use strict;
use warnings 'all';
my( $account, $password ) = #ARGV;
open QUERY,
"curl --sslv3 --user '$account:$password' https://Linksys/ --silent |"
or die "Failed to connect to router";
my #ipaddr = ('x','x','x','x');
while( <QUERY> ) {
$ipaddr[$2] = $1 if /value='(\d+)' name='wan_ipaddr_([0-3])/;
}
close QUERY;
print join('.', #ipaddr);
There is no guarantee that this will work with all versions of the router firmware.
If your router is set to use http for this interface, drop the --sslv3 curl option, and you can use dotted-decimal notation to address the router. To use https with the curl options above, I also did this:
Used a browser to fetch the router's self-signed certificate (saved as Linksys.crt).
Added it to my CA bundle:
openssl x509 -in Linksys.crt -text >> /usr/ssl/certs/ca-bundle.crt
Added 'Linksys' to my hosts file (C:\Windows\System32\Drivers\etc\HOSTS on my Win8 box), as an alias for the router's address. If the dotted-decimal notation is given to curl instead of this alias, it rejects the connection on account of a certificate subject name mismatch.
Alternatively, you could just use the --insecure option to bypass certificate verification, which probably makes more sense in the circumstances.
whatismyip.com or ipchicken.com are very easy to parse.
If you have a webhost or vps you can also determine it, without fear of it randomly going down leaving you stuck.
ifcfg.me
allows Lookup via
nslookup
telnet
ftp
and http
even works with IPv6
Simple but not elegant for this use. I created a VBS file with the following code to drop the result to dropbox and google drive ... have to delete the file for new one to sync though for some reason.
This runs on a PC at my home. My PC is set to resume on power outage and a task is scheduled to run this every day once (note if you have it run often, the site will block your requests).
Now I can get my IP address on the road and watch people steal my stuff :-)
get_html "http://ipecho.net/plain", "C:\Users\joe\Google Drive\IP.html"
get_html "http://ipecho.net/plain", "C:\Users\joe\Dropbox\IP.html"
sub get_html (up_http, down_http)
dim xmlhttp : set xmlhttp = createobject("msxml2.xmlhttp.3.0")
xmlhttp.open "get", up_http, false
xmlhttp.send
dim fso : set fso = createobject ("scripting.filesystemobject")
dim newfile : set newfile = fso.createtextfile(down_http, true)
newfile.write (xmlhttp.responseText)
newfile.close
set newfile = nothing
set xmlhttp = nothing
end sub