After installing TeamViewer, I have changed the wampserver port to 8080, so the address is http://localhost:8080.
For the host file located at C:\WINDOWS\system32\drivers\etc\, I have also made the change as below
BEFORE
127.0.0.1 www.example.com
AFTER
127.0.0.1:8080 www.example.com
When I access www.example.com, it doesn't redirect to my wampserver, how can I fix it?
I managed to achieve this by using Windows included Networking tool netsh.
As Mat points out : The hosts file is for host name resolution only, so a combination of the two did the trick for me.
Example
Overview
example.app:80
| <--Link by Hosts File
+--> 127.65.43.21:80
| <--Link by netsh Utility
+--> localhost:8081
Actions
Started my server on localhost:8081
Added my "local DNS" in the hosts file as a new line
127.65.43.21 example.app
Any free address in the network 127.0.0.0/8 (127.x.x.x) can be used.
Note: I am assuming 127.65.43.21:80 is not occupied by another service.
You can check with netstat -a -n -p TCP | grep "LISTENING"
added the following network configuration with netsh command utility
netsh interface portproxy add v4tov4 listenport=80 listenaddress=127.65.43.21 connectport=8081 connectaddress=127.0.0.1
I can now access the server at http://example.app
Notes:
- These commands/file modifications need to be executed with Admin rights
- netsh portproxy needs ipv6 libraries even only to use v4tov4, typically they will also be included by default, otherwise install them using the following command: netsh interface ipv6 install
You can see the entry you have added with the command:
netsh interface portproxy show v4tov4
You can remove the entry with the following command:
netsh interface portproxy delete v4tov4 listenport=80 listenaddress=127.65.43.21
Links to Resources:
Using Netsh
Netsh commands for Interface IP
Netsh commands for Interface Portproxy
Windows Port Forwarding Example
The hosts file is for host name resolution only (on Windows as well as on Unix-like systems). You cannot put port numbers in there, and there is no way to do what you want with generic OS-level configuration - the browser is what selects the port to choose.
So use bookmarks or something like that.
(Some firewall/routing software might allow outbound port redirection, but that doesn't really sound like an appealing option for this.)
What you want can be achieved by modifying the hosts file through Fiddler 2 application.
Follow these steps:
Install Fiddler2
Navigate to Fiddler2 menu:- Tools > HOSTS.. (Click to select)
Add a line like this:-
localhost:8080 www.mydomainname.com
Save the file & then checkout www.mydomainname.com in browser.
Fiddler2 -> Rules -> Custom Rules
then find function OnBeforeRequest on put in the next script at the end:
if (oSession.HostnameIs("mysite.com")){
oSession.host="localhost:39901";
oSession.hostname="mysite.com";
}
The simplest way is using Ergo as your reverse proxy:
https://github.com/cristianoliveira/ergo
You set your services and its IP:PORT and ergo routes it for you :).
You can achieve the same using nginx or apache but you will need to configure them.
This doesn't give the requested result exactly, however, for what I was doing, I was not fussed with adding the port into the URL within a browser.
I added the domain name to the hosts file
127.0.0.1 example.com
Ran my HTTP server from the domain name on port 8080
php -S example.com:8080
Then accessed the website through port 8080
http://example.com:8080
Just wanted to share in case anyone else is in a similar situation.
If what is happening is that you have another server running on localhost and you want to give this new server a different local hostname like
http://teamviewer/
I think that what you are actually looking for is Virtual Hosts functionality. I use Apache so I do not know how other web daemons support this. Maybe it is called Alias. Here is the Apache documentation:
Apache Virtual Hosts examples
-You can use any free address in the network 127.0.0.0/8 , in my case needed this for python flask and this is what I have done :
add this line in the hosts file (you can find it is windows under : C:\Windows\System32\drivers\etc ) :
127.0.0.5 flask.dev
Make sure the port is the default port "80" in my case this is what in the python flask: app.run("127.0.0.5","80")
now run your code and browse flask.dev
Using netsh with connectaddress=127.0.0.1 did not work for me.
Despite looking everywhere on the internet I could not find the solution which solved this for me, which was to use connectaddress=127.x.x.x (i.e. any 127. ipv4 address, just not 127.0.0.1) as this appears to link back to localhost just the same but without the restriction, so that the loopback works in netsh.
You need NGNIX or Apache HTTP server as a proxy server for forwarding http requests to appropriate application -> which listens particular port (or do it with CNAME which provides Hosting company). It is most powerful solution and this is just a really easy way to keep adding new subdomains, or to add new domains automatically when DNS records are pointed at the server.
Apache era call it Virtual host ->
httpd.apache.org/docs/trunk/vhosts/examples.html
NGINX -> Server Block
https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/
Alternate way
Install Redirector
Click Edit redirects -> Create New Redirect
Related
Due to several circumstances, I need to configure my windows client to be able to receive through another port than 445 or 139 with Samba communication. The idea is to avoid as much as possible having to install any additional program in windows 10, or if necessary, that it could be configured through code in c++. For my tests, the samba server is running on a Linux machine.
First of all, I’ve tried the samba communication without changing the port and it works perfectly, executing in windows (Start→Run): \\[Ip_Server]\
To change the port in the server, I've added the line smb ports = 2000(this port number is just for the example) in the "/etc/samba/smb.conf" file and checked the change with:
netstat -an| grep -iE ":2000".
After that, in the client I've tried the following steps:
To disable Samba 1.0
To delay the startup of the lanmanserver driver:
sc config lanmanserver start= delayed-auto
To check if the IpHlpSvc driver is running:
sc config iphlpsvc start= auto
To add a portproxy rule to reroute TCP port 445 to the port 2000 (of course, rebooting after that)
netsh interface portproxy add v4tov4 listenaddress=[Ip_client] listenport=445 connectaddress=[Ip_client] connectport=2000
(I've tried this step with both IPs, client’s and server’s, and changing the order of the ports). After that, I try again the samba connection, and I'm not able to connect with the server.
If anyone knows what the problem might be and has a solution, it would be helpful.
I've created SSH tunnels in the past, but I'm having trouble on OSX. I'm looking to take a website's port 80, and direct it to my localhost:8080. When I run this command
ssh -L 8080:<cloud_ip_address>:80 root#<cloud_ip_address> -N
I get the default apache 'it works!' page.
Why am I not getting the port 80 of the remote machine (which is running a web app)?
UPDATE
I still do not have a solution yet, but I have some more information. The page I am getting is the default page in /var/www/html but I am serving a Flask app which does not have static pages.
Because HTTP protocol contains not only the IP address, but also the hostname (the URL you type into your browser), which differs between the <cloud_hostname> and localhost. The easiest way to trick it is to create /etc/hosts (there will be some OSX alternative -- search ...) entry redirecting the hostname of your remote machine to localhost.
127.0.0.1 <cloud_hostname>
But note that in this case you will not be able to access the remote machine using the hostname!
I have a server(AWS) to which I have ssh access.
There is a service(supervisor) running on this service on port 9001 whose web view can be accessed through 127.0.0.1:9001 had it been a local machine.
But since it is not a local machine, how do I access it?
I got the ip address of the machine using ifconfig | grep inet and then tried accessing it through https://172.11.11.1:9001/
Bit dint work.
When I tried wget https://172.11.11.1:9001/ it shows
Connecting to 172.31.19.8:9001... and hangs there.
I have added the following line in my supervisor conf file.
[inet_http_server]
port = *:9001
Can someone please help me with this?
This is more of a server config question. You'll most likely find your AWS access properties allow connections on post 22, 80 and 443 only. In AWS console you'll need to add a new security access group to allow port 9001 to be accessed.
So I'm using dnsmasq for my local dev environment & I need to set it up to use multiple domains ex. (.dev, .test, .somethingelse) how can this be done?
currently It's working with .dev only
this is how my dnsmasq.conf looks like
address=/dev/127.0.0.1
listen-address=127.0.0.1
For every (sub)domain you want to server locally, add the following entry to your dnsmasq.conf:
address=/.domain/127.0.0.1
Now let your OS know, that you want to redirect requests to this domain to your local dnsmasq nameserver. Do this by creating a file "domain" in "/etc/resolvers".
/etc/resolvers/domain has the following content:
nameserver 127.0.0.1
More info about the resolver thing.
A more generic answer would be to have in /etc/dnsmasq.conf
local=/mylan/
and in /etc/hosts
192.168.1.3 dev dev.mylan
192.168.1.3 test test.mylan
192.168.1.4 build build.mylan
as per https://serverfault.com/questions/136332/setting-up-dnsmasq-for-a-local-network
(note that the solution comes in aid for the DHCP settings where you cannot have 2 hosts on the same IP, as the OP liked)
for me, address=/.aaa.com/.bbb.com/127.0.0.1 do the trick.
.dev is not recommended to be used in development as Google actually owns that top level domain.
You might want to use reserved TLDs, like .localhost, for development.
Good article about the same problem: https://web.archive.org/web/20180722223228/https://iyware.com/dont-use-dev-for-development/
In your /usr/local/etc/dnsmasq.conf add:
address=/dev/test/127.0.0.1
And then create files:
/etc/resolver/dev and /etc/resolver/test. Both with content:
nameserver 127.0.0.1
From now all xyz.dev and xyz.test domains will point to 127.0.0.1.
When I check using Apache > Service > Test Port 80, then it shows
Your port 80 is actually used by :
Server: Microsoft-HTTPAPI/2.0
How can I disable this. Tried every possible way, even via registry, and stopping World Wide Web Publishing.
I don't think that's possible. When you type "localhost" into the browser, it resolves that to "127.0.0.1", and fills in the default port of 80. If nothing is listening there, it won't connect. It can't resolve "localhost" to "127.0.0.1:8080". If you can't use port 80, you have to specify the port you want. Use a bookmark if it makes it easier for you.
This is basically redirecting 127.0.0.1:80 to 127.0.0.1:8080
Win7 has no iptables equivalent. Writing a server that does what you want (listens on a port, copies everything to/from another) should be easy enough. You can find one at this URL: http://www.quantumg.net/portforward.php
$> netsh
$> interface portproxy
$> add v4tov4 listenport=xxx connectaddress=127.0.0.1 connectport=yyy protocol=tcp
[or]
port forwarding in windows
Suggestion: If your Apache is under your WIn10
Under Win Settings:
- Proxy - Manual proxy setup - Use a proxy server - Turn On
- Type under Manual proxy server http=127.0.0.1:8080;https=127.0.0.1:8080
- Press the Save button
and tell me if it is working.