Jump to content

users accessing my localhost


Go to solution Solved by requinix,

Recommended Posts

hey guys,

 

i'm trying to set up router so my local host can be visible to users...I've altered options in my router port forwarding but i'm unable to get it to work.

 

i'm currently using nginx on my local host using port 8080 so i'm able to connect via: http://127.0.0.1:8080/

 

here are the options i've changed in my router: (port 21 for FTP 80 for nginx server)

 

Untitled_2.gif

 

after there alterations i've tried to connect with my ip followed by the port (ip:80) and also http://192.168.1.1:80 but its not working.

 

can anyone please give me advise on how i can get this working?

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/299728-users-accessing-my-localhost/
Share on other sites

First of all, are you sure your Web server is actually listening on it's LAN port?   Localhost/127.0.0.1 is not the LAN port for your machine.  It would be whatever the IP on 192.168.1.x is.

 

I'm not sure what you need to do this for, but I'm going to give a plug to https://ngrok.com

 

It's an alternative to what you're doing, that might be more flexible and convenient than screwing around with your router and opening up a port forward.  

 

Last but not least, you will not be able to easily test the port forward from your internal network.  Only a machine outside your network can actually hit the router, so you'll need some way to test it other than trying to use a browser on the same machine, or some other machine at your house.

  • Solution

1. The server has to be listening on your LAN IP address. 127.0.0.1 will only work for connections from the same computer.

2. Make sure your firewall allows inbound connections to that port.

3. Set up a port forwarding on your router from whatever port to your LAN IP address (and port).

I'm not sure what you need to do this for, but I'm going to give a plug to https://ngrok.com

 

brilliant that worked like a charm....also very east to use and it broadcasted thanks gizmola

ngork http 8080

requinix i'd like to know how to do it via my router also....here is what i've done.

 

nginx operates on port 8080 locally...i've added a port forwarding on my router (port 80) for port 8080 (nginx) as seen in image above...

i just added a rule in firewall for port 80 to be public, but i noticed there is a few other things that operate on port 80 in my firewall....so should i make it unique?

 

here is my nginx conf...do i need to alter this too?

worker_processes  1;
error_log logs/error.log;

events {
	worker_connections 1024;
}

http {
	keepalive_timeout  	300;
	proxy_read_timeout 	300;
	proxy_connect_timeout 	300;
	fastcgi_read_timeout 	300;

	server {
		listen 		8080;
		server_name 	127.0.0.1;
		client_max_body_size 	500M;

		index index.html index.htm index.php;
		root 	c:/nginx/html;

		location / {
			autoindex on;
		}
		
		location = /favicon.ico {
  			log_not_found off;
		}

		location ~ .php$ {
			fastcgi_pass 	     127.0.0.1:9000;
 			include 	     fastcgi.conf;
			fastcgi_index 	     index.php;
			fastcgi_read_timeout 300; 
		}
	}
}

thank you for your help guys

The nginx server needs to be listening on your LAN address too. As in 192.168.1.x.

And the port for the firewall rule is the one that nginx uses. 8080. Your computer doesn't know anything about what the router is doing.

 

i just added a rule in firewall for port 80 to be public, but i noticed there is a few other things that operate on port 80 in my firewall....so should i make it unique?

What do you mean? What things? Make what unique?

 

If there isn't already a rule set up for nginx then you'd need to make one: make a new firewall exception for a particular program (and find nginx.exe or whatever) so the rule doesn't grant access to everything, then allow access to port 8080 and any remote host.

  • Like 1

ok notes taken thank you.

 

nginx config:

listen 		8080;
server_name 	192.168.1.80;

i've made port 8080 as a new inbound rule on my firewall for nginx.exe and port 80 on my router forwarding to port 8080 :)

 

now when i get someone to try connecting to my (ip):80 it doesn't connect...any ideas on this please requinix? i'm sure i've done everything right

 

 

thank you

ok i turned off my windows firewall completely but im still getting no joy...if you could please help...

 

 

here is the rule i did for my firewall

 

firewall.gif

 

 

opened port 8080 on my router

 

 

router.gif

 

followed by my nginx config containing 192.168.1.80

error_log logs/error.log;

events {
	worker_connections 1024;
}

http {
	keepalive_timeout  	300;
	proxy_read_timeout 	300;
	proxy_connect_timeout 	300;
	fastcgi_read_timeout 	300;

	server {
		listen 		8080;
		server_name 	192.168.1.80;
		client_max_body_size 	500M;

		index index.html index.htm index.php;
		root 	c:/nginx/html;

		location / {
			autoindex on;
		}
		
		location = /favicon.ico {
  			log_not_found off;
		}

		location ~ .php$ {
			fastcgi_pass 	     127.0.0.1:9000;
 			include 	     fastcgi.conf;
			fastcgi_index 	     index.php;
			fastcgi_read_timeout 300; 
		}
	}
}

hope you can tell me where i've gone wrong?

 

thank you

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.