website 404 error from external webbrowser - xampp

I can't get access to my website from external over the ip adress.
this works:
localhost/my_website // shows my web_site
https://IP-adress/ // I see xampp startpage
this doesn't work:
https://IP-adress/my_website //-> I get 404 error
when i add to the httpd.config file "listen 443" or "listen 80" the server doesn't start.
info: I'm using lubuntu(ubuntu)
Edit:
at pre-conclusion at least it has nothing to do with "listen "
The point is that just the folder /my_website,which shows my_website can't be shown from external computer,but xampp for an example is shown from external
I

You probably need to specify a host address, as well as a port. It's been a few years since I used xampp, but I'm guessing it defaults to localhost if no address is explicitly provided.
So, rather than "listen 80"/"listen 443", try "listen <ip address>:80"/"listen <ip address>:443".
For example: "listen 0.0.0.0:80" would allow you to reach your server from your local machine using both localhost and 127.0.0.1.

Related

where does localhost name get resolved on windows?

clearly localhost name on windows is resolving on same place other than hosts file:
line 127.0.0.1 localhost has a # on the beginning so it will be ignored
on lines above, it's said that localhost gets resolved within DNS itself
I've set a custom local URL on hosts file (via Laragon) which is working fine on normal situation; however, when I connect my vpn extension on chrome, this & all other defined local names fail to load page:
dial tcp: lookup <URL> on 127.0.0.11:53: no such host
well, all except localhost. localhost domains get resolved on all situation & I'm thinking this is because localhost is defined on someplace deeper than hosts file; & if that place can be modified, then I can add my domain to it so my domain will work on every situation too.
so where does localhost get resolved on windows & how can i add custom names in that place?

OSX SSH tunnel from remote port to local

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!

Phpstorm + xdebug : Remote host is configured as "localhost" despite server host is probably not local

I was following this instruction to validate my debugger configuration on Web Server. I uses a remote server whose FTP connection has been tested, but I get this warning message saying
Remote host is configured as 'localhost' despite server host is probably not local
My first question is: what does "remote host" and "server host" refer to respectively?
I know remote host is the setting xdebug.remote_host, and according to the xdebug documentation, it is "the host where the debug client is running".
This makes me confused: Isn't the debug client the IDE I am running on my local machine?
If yes, then shouldn't "the host where the debug client is running" be my local machines's IP address? If yes again, should I configure xdebug.remote_host to be my IP?
I tried setting it to my IP, the warning message does't show but it doesn't feel right because later I tried it with a random IP the message also doesn't show.
Secondly, the xdebug documentation also says that this xdebug.remote_host setting will be ignored if xdebug.remote_connect_back is enabled." Although not quite sure what this setting does, I set it to be "On", as the picture shows:
I was hoping this will eliminate the warning message, but it is still there. So how do I get rid of this message?
In my case, I had several apache virtual hosts setup for different projects. I was able to access projects via different urls, like : http://projectname1, http://anotherproject2 .
I was getting that same error in PhpStorm while doing xdebug validation:
Remote host is configured as “localhost” despite server host is
probably not local
Problem was fixed, once in php.ini xdebug.remote_host matched the URL of the project I was debugging. So, if I was debugging http://project1, I would have this in php.ini:
xdebug.remote_host="project1"
Having values as 127.0.0.1, or localhost didn't fix it.
Hope it helps someone.
Did you try with following?
xdebug.remote_host = "127.0.0.1"

how to redirect example.com to 127.0.0.0/main/test?

i'm using wamp 5, windows XP. i have edited my host file in my local disk like the code below and it works
127.0.0.0 example.com
but i'd like to redirect to a particular folder, if i change it to the code below, it dont work
127.0.0.0/main/site example.com
how to redirect example.com to 127.0.0.0/main/site locally in my PC?
btw, i dont want to install any new software to solve this prob
You need to create a Virtual Hosts
Leave the HOST file as
127.0.0.1 example.com
When you define a Virtual Host you also tell it which folder is its DocumentRoot so that will send it to the right place when you use the address example.com in the browser.
Check out wampserver.com

Using port number in Windows host file

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

Resources