I am trying to redirect http://www.club.example.com to something, but ONLY if they use the port 25565. If they go to port 80, it will redirect them to a website. So basically:
It should be worth noting if it goes to the Minecraft server, that is running on my computer and can be accessed with my_public_ip:25565.
In php you can do like this:
<?php
$port=$_SERVER['SERVER_PORT'];
if ($port==25565)
// redirect minecraft server
else
// show website
?>
Related
I'm trying to create a simple local web-server that collects real time data from a remote server. The remote server is not under my control and it streams out text lines continuosly.
I think scocket.io is Ok for that purpose but I'm really new to node.js and I don't know where is the problem. I've installed socket.io with:
npm install socket.io
then I wrote a simple index.html page deployed in my www dir:
<!DOCTYPE html>
<html>
<head>
<script src="socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://192.168.1.100:8888');
socket.on('data', function(msg) {
var val = msg;
$('#data_value').html(val);
})
</script>
</head>
<body>
<h1>Data Stream</h1>
lines: <span id="data_value"></span><br/>
</body>
</html>
When I load index.html with the browser I can see the web page with the correct title and the the string "lines:" but no data is printed out.
If I try to directly browse the remote server at http://92.168.1.100:8888 I can see the stream.
Can you help me?
92.168.1.*, is the home ip address for routers. You say that the server isn't under your control but it's still being run from the same router your client is trying to connect to.
So you're listening for a call from a server, on port 8888 but this server is a local one. If someone else is running this server you're going to need to ask them to portforward it and send them their public ip address, otherwise your website is just waiting for your PC to be hosting this server and send you the data :(
I think you have misunderstood how socket.io works.
The problem seems to be in socket.on part of your code. Socket.io only responds to socket.io broadcast events not a stream of strings that is being updated by a server.
Is 192.168.1.100 server a socket.io server? If not then your web app will not work as a socket.io client.
I have created an HTML page on my PC and I need to run it in my mobile for testing. I have deployed it in TOMCAT and I run it using http://IP ADDRESS (192.something.something.something):port/index.html
I can't access it outside my home network. I want to know do I need to add something to make it run outside my home network on other mobile phones..? I am confused.. Everything is new for me. Will appreciate any help. Thanks
You may need to check the config settings from your internet service provider to make sure that the Port is open and you are not blocking outside connections via the port or IP address.
Go to your browser and type in your IP address, this should take you to your router settings and check the settings there.
Good luck!
Say I have this HTML page , I want when some one on my local network type my(ip) or my computer Name in a browser to view that HTML page
You just have to edit the httpd configuration file and ensure that the default port is set to 80, as by default it should use that anyhow, 8080 is the alternate one.
If you use a local network then the rest of the users in it should be able to reach the website on http://your-computer-name, otherwise if for any other reasons that's not configured then they'll have to use the IP address.
They can also edit their local hosts file (in Windows for eg.) and have something like:
your.IP any-name
any-name being either your computer name or website name, as it will be a direct maping
I am having a strange issue with Apache, Wordpress, and CodeIgniter. I have a laptop which I use for web dev, and it works fine. However, when I tried to access the sites hosted on the laptop's Apache installation through its IP address, the CSS would not load. When I examined the page source, it listed the path of the CSS file as http://localhost/css/site.css, even though I was accessing the page remotely.
I am running Wordpress and CodeIgniter on the same server, in different subdirectories. On the CodeIgniter header templates, I use <?php echo base_url('/css/style.css');?> to access the style, and on Wordpress <?php bloginfo('stylesheet_url'); ?>. Furthermore, when trying to access the admin panel on Wordpress, I am redirected from http://10.0.0.1/wordpress/wp-admin to http://localhost/wordpress/wp-admin, which breaks the admin panel too.
Strangely, this issue does not appear on the pure HTML sites, where I use a relative path for the CSS.
I suspect the problem lies with the WP and CodeIgniter config files, which have the domain of the sites listed as localhost. Another source of the problem could be the Apache config, but I have no idea where to start looking for it.
I fixed the CodeIgniter issue by going to the config.php file and setting:
$config['base_url'] = '';
The Wordpress fix is temporary, until I can set up my DNS server to serve local hostnames. I put the Wordpress Home and Site URLs to the local IP address. This works for the moment, but if I switch networks, it will break again.
I am having a bit of a problem with HTML5 & WebSockets.
I have put together a very simple client / server application to pass strings to each other and all works well when I am accessing the client html page via a local file path or via http://localhost, however when I try and call it from http:// or http:// it doesn't seem to work.
The first thing the client does is check if the browser supports Web Sockets:
if (!window.WebSocket) {
_Status.innerHTML = "Web Sockets not support by this browser";
return;
}
When I browse to the page with the local host address window.WebSocket is true, but when I use anything else, the page works but window.WebSocket is false.
Am I missing anything obvious? Is it an IE permissions/trust issue?
I am using IE10 and Windows 8 Consumer Preview.
I am out of ideas. Has anyone got any ideas?
WebSockets uses TCP protocol layer to connect.
Server opens Socket and Binds it to specific Port. Then it listening port and accepting connections.
If you are trying to connect to your server, make sure that you use right external IP and you probably need to set up Port Forwarding on your router to your computer, that router will know where to redirect packets.