Kohana accessing client ip - kohana

I am using kohana 3.2, and i would like to acces client ip from request class, in documentation i can see public static string $client_ip which should contain client ip, now if i try to access it i like so:
Request::$client_ip;
I get: string(3) "::1" it makes no sense at all, what am i doing wrong, or maybe it's impossible to access it?

You access your script locally, your IPv6 address is ::1

Related

How to allow specific URL for specific IP adress?

I would like to ask, can anyone here advise on how to have a specific web address enabled to display only at a specific IP address that I choose?
I've only got HTML basics, and nowhere have I found a way to get this or are there any storage sites that support this?
I want it for storing a script I don't want to have publicly and I need it fixed to an IP address.
javascript:$.getScript('secret url);void(0);
Thank you
You will need to blacklist all other IPs and whitelist the IPs you want it to have access to.
Shared Hostings will have their own GUI for doing this but if you're hosting your app using a VPS (Virtual Private Server).
The most common approaches are:
Option #1: Through Web Server (Nginx, Apache, etc...)
Nginx
https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-proxied-tcp/#restricting-access-by-ip-address
Apache
https://httpd.apache.org/docs/2.4/howto/access.html
Option #2: Through Backend Server (PHP, Ruby, etc...)
PHP IP Address Whitelist with Wildcards
Note:
You will need to have your HTML page rendered using one of these
approaches to make it work.
The flow would look like this:
User visits the page -> Web Server Checks If the IP is allowed ->
Backend Server Checks if the IP is allowed (optional) -> Serve the
HTML.

Can rocket.chat be server on 2 interfaces at the same time?

here is the situation,
we have a domain, let's say example.com
I have added a subdomain to the dns, chat.example.com
I have modified the Caddyfile inserting http://chat.example.com (it works fine)
However, rocket.chat is hosted on our local server, and it is behind the router provided by our ISP, which apparently is programmed to return its own home page if an address is typed that resolves to its external ip address. In other words, if a computer located inside our local network types http://chat.example.com, it gets the router home page (the one where you can configure it).
I have solved it by modifying the hosts file, but I would prefer a cleaner solution. Is there anything that I can do on the Caddyfile, perhaps allow him to reply on 2 interfaces (http://chat.example.com and http://192.168.1.x), or something else that I have not thought yet?
Thank you!

Why have I stopped being able to access a website from an ip that is allowed in htaccess?

I have been using this code for a while in .htaccess:
order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx
Everything worked fine and I was able to access from xxx.xxx.xxx.xxx, while others could not access and got a 403 error.
A few days ago, though, I started getting the 403 error when accessing via my laptop from xxx.xxx.xxx.xxx. The strange thing is that when I access from my mobile phone, using the same IP, everything works fine.
If I delete the contents of .htaccess, then my laptop can access the website, but add the contents again and then it can't.
I am pretty sure the code in .htaccess is correct, since it worked before.
I get the ip I am using by googling "what is my ip". Is there another IP I should be using?
I had some problems with FileZilla that same day and may have made some changes related to that... but I can't remember doing anything that I didn't undo.
Any suggestions would be much appreciated.
Sometimes a client accesses a server through IPv6, which is the most recent Internet protocol and successor to IPv4.
IPv6 has a different kind of IP addresses, and therefore Apache doesn't recognize your laptop anymore.
To enable your laptop via IPv6 as well, you may give an appropriate IPv6 address to Allow, e.g.
Allow from 2001:db8::a00:20ff:fea7:ccea
This may be given in addition to the IPv4 address, so you may connect either way.

How does my local HOSTS file resolve but IP will not

I'm in the process of launching a new website. I migrated all the code to the new server. The admin at the new host told me that I have to add an entry to my hosts file and then I will be able to see the website. So essentially he had me add:
111.222.3333.4444 example.com www.example.com
These are example, but after doing this, it worked. My question is, is how? If I visit the IP directly in my browser I get a 403 Forbidden error. Does the host have a way to resolve this IP to a location on their server if resolved from a domain name? I'm just confused as to how this works. I understand that by changing the IP address I can get the domain name to resolve to any IP, but I'm wondering why, on the hosts end, does this now resolve this way, but not by typing in the IP directly.
Thanks!
Does the host have a way to resolve this IP to a location on their
server if resolved from a domain name?
Not exactly. Your browser, when sending the request to the IP address, will send one important piece of information called 'Host header', that is the actual host name as you typed in your browser.
You usually can not open the website just by entering the IP address in your browser's address bar because web servers (and possibly many other network components that are between you and the web server) often do not host only one web site on that IP address so they rely on exact domain name typed in address bar to serve the right content.
You can test this by using one of the browser add-ons that allow you to add your own headers. Add header named 'Host' with the value 'example.com' and with that try to open your site by typing only provided IP address.

Make original site url name to some fake url name

I am new to rewrite site url name. I have a site url like http://66.15.101.250/test/ . this is my owned server link So i want to change this site url to something other name like http://testsite/test/ ( i do not want to give domain name to this ip address url).And i have otheres site running on this http://66.15.101.250/test/ server . I have no idea how to do this, what should i do.
Is this possible through .htaccess file or something else
Thanks in advance
Your server can only respond to requests it receives, and will only receive requests routed to it by DNS, so if you don't own the domain name, you can't receive public traffic directed towards it. You could silently redirect users from
http://66.15.101.250/test/ to the content found at http://testsite/test/ but they would still see the http://66.15.101.250/test/ url in their browser.
If you think about it, its a good thing you can't do this or I could make stealyourcreditcardinfo.com appear as paypal.com. Indeed most uses for what you are asking about would not be legitimate ones...
For your own internal testing purposes, you can make virtual host entry for testsite.com and your server will respond to any requests it receives for testsite.com. You then change your HOSTS file to point testsite.com to 127.0.0.1 and testsite.com will work in your browser, but only on your machine because you manually overrode your own DNS. The DNS everyone else is using is still pointing testsite.com to the actual IP address somewhere else
If you need this for testing purposes (as it seems to me), you can put 66.15.101.250 testsite in your hosts file and configure a virtual host for testsite in your webserver.

Resources