Localhost 's subdomain with port numbers, how to? - subdomain

We know that to add a subdomain for localhost, we open and edit the host file by adding lines such as:
127.0.0.1 localhost
127.0.0.1 abc.localhost
127.0.0.1 xyz.localhost
My problem is that: if I browse abc.localhost:88 I get the below error:
Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid.
Why doesn't the URL abc.localhost:88 browse to 127.0.0.1:88 ?
Please help.

Because you need to an entry for abc.localhost to your hosts file. If you already have, then make sure that your webserver is listening on port 88.
If you are using IIS, make sure that you have added a binding to the correct hostname (abc.localhost).

As well as putting the entry in the client's hosts file, you will need to add the appropriate host header abc.localhost to the IIS site that's configured for port 88.
In IIS manager (inetmgr.msc), website properties, website tab, advanced, and add your host header there.

Related

SSRS HTTPS not working for localhost / IP (Bad Request - Invalid Hostname)

I have added https binding to my SSRS but somehow it only work with hostname but not localhost and IP, http is working fine for hostname, localhost and IP.
HTTP
https://mypc:123/Reports -> Working
https://192.168.1.22:123/Reports -> NOT Working (Bad Request - Invalid Hostname)
https://localhost:123/Reports -> NOT Working (Bad Request - Invalid Hostname)
HTTP
http://mypc/Reports -> Working
http://192.168.1.22/Reports -> Working
http://localhost/Reports -> Working
Is the any misconfiguration?
Thanks.
Firstly, make sure you configure your https settings correctly in Report Server Configuration Manager. Second, your https port is 443 and not 123. Ex: https://localhost:443/Reports.
The reason might be that the HTTPS configuration was done using a certificate with CN=mypc; if you want to access the Report Server using IP or LocalHost(For some reason) then try creating a certificate with multiple CN values.
But I don't think its a valid use case as IP might change and localhost might not be accessible from clients.

How to change https default port but not include it in the URL

I have a website on 2 different servers. And I would like to access the site on server #1 by going to https://www.example.com/ (on port 80) and access it on server #2 by going to https://www.example.com:4567/
But the problem is that I need to hide the port number from the address bar. With port 80 it is hidden by default. But if I change it to a different port then it is visible. For example if I do console.log(window.location.href) on the server I will see https://www.example.com:4567/ (with port included).
Is it possible to tell Google Chrome that the default port is not 443 for HTTPS but instead 4567? I could not find anything in the settings that could do that.
I think I found a solution for my problem. Although it requires that I access the website from a specific IP address.
I was able to set up port forwarding in my router in such a way that all incoming requests from my IP address get automatically forwarded to not only a local IP but also a specific port number.

hotlink working locally, not in server

I want to hotlink an image from a remote website. This works when I test in my local PC (Apache server), but doesn't work when I try from my website.
I am not an expert in this subject, but as I understand if hot-linking was blocked in the remote site, it should not work in my local server as well, right? In that case what might be the issue (my hosting provider is saying they don't have any issue)?
Let's play this through.
On your local server:
You make a request to 127.0.0.1 (or localhost) that returns some HTML with a hotlinked image to example.com.
The browser makes a subsequent request to example.com and sets the referer header to 127.0.0.1.
Now example.com has to determine whether the referrer is allowed to hotlink or not.
Since, for that server, example.com and 127.0.0.1 both refer to the same thing, namely the server itself, this looks like a valid request.
On your remote server:
Same as above, but replace 127.0.0.1 with your.favourite.url.
This time when the server validates the referrer, it will come to the conclusion that your.favourite.url and example.com do not refer to the same thing, and therefore block the image request.
This could be seen as a misconfiguration of example.com, since the referrer might not resolve to the same point from both client and server context.
If you access your local server via your local network IP (e.g. 192.168.1.42), then hotlinking should no longer work, unless example.com has a really graceful referrer policy, or happens to use exactly the same local IP as you.
It could also be possible to expose example.com's local IP by brute-forcing all local network IPs, though while that technically is an information leak, there's not much you can do with it.

How to set up www directory to public? WAMP

I cant seem to find any good solution for my issue so I hope this question will be answered once and for all.
First, I understand that by hosting my html files online directly from my PC means to loosen up my PC security and that can be dangerous. But I am fine with this as this is just my testing laptop. Nothing important or whatsoever in here.
So lets start with the main issue. I have port forwarded the port 3306, 80, 8080, and 2727(which I plan to switch the apache port to this)
Tested port online and result is open.
In my apache httpd.conf file, here is what I have setup..
Listen 0.0.0.0:2727
ServerName xxx.xxx.x.xx:2727 (which is my private ip)
<Directory "c:/wamp/www/">
Options FollowSymLinks Indexes
Allow from all
Order Allow,Deny
AllowOverride All
Require all granted
</Directory>
I am now able to access my index.html in the wamp www directory by typing 127.0.0.1:2727 in the url (same goes to /phpmyadmin)
What should I do next to make sure my public ip can access the index.html?
Example, when I enter my public ip like this 175.162.154.18:2727, it just shows connection timed out.
Extra info if this helps :
My WAMP is orange.
I have the MYSQL Community Edition in my PC.
My WAMP version is 2.5
Apache version is 2.4.9
MySQL version is 5.6.17
Apache service test port 80 is not used.
I apologize in advance if my question seems difficult to understand but I will try my best to provide as much information as per request.
Modify apache httpd.conf file
Listen 2727
Basically WAMP and MySQL Community Edition does not work quite well together.
What I did was uninstall every program and files related to MySQL and WAMP. Restarted my PC and continue to delete existing folder related to both MySQL and WAMP.
Then, I installed a fresh WAMP again and it is finally green in color! Hooray!
So I head over to the httpd.conf file and edited Listen 80 since it is the default and my ISP is not blocking port 80 and ServerName 192.168.0.x:80 which is my Private IP address. I did not modify any other than this in the file and when I type my public ip by using my mobile data network, it connected successfully to my local website!
Conclusion to set-up your own website ONLINE on your PC (with WAMP) :
Obtain your private ip address (can be obtained from cmd by typing ipconfig)
Login to your router and port forward the port 80 (or another if your ISP is blocking port 80) under your PRIVATE ip address. Note : I port forwarded both TCP & UDP.
In Apache httpd.conf file, edit the Listen to your port number that you have port forwarded. (Eg. Listen 80)
Edit the ServerName below to ServerName xxx.xxx.xx.xx:80 where the ip is your private ip address. If you use a different port, change the 80 to your own port.
And basically that is it! Type your public ip in your browser url and done! Note: If you use another port you will need to type in your port number as well eg. 177.122.140.13:8080 (If port 8080 is what you chose)
Result :

Why does WAMP says this:"Forbidden You don't have permission to access / on this server."?

So I installed WAMP on Windows 7 and port-forwarded my Privat IP and I tried using my Public IP, but no luck.It's just giving me this error: Forbidden
You don't have permission to access / on this server.I tested it out with localhost and 127.0.0.1 and it worked, but with my Public Ip it dosen't.Please Help me!
It is because of the settings in you httpd.conf file. To correct the problem, follow the steps-
Click on the wamp icon.
Go to, Apache -> httpd.conf
Now search for "Controls who can get stuff from this server."
See below that, there should be a line "Deny from all".
Change it to "Allow from all".
To allow your Apache server to be accessed from the internet you need to tell Apache that it is allowed to accept connections from any IP address
Edit httpd.conf using the wampmanager menus links.
Find this snippet in the config file
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
And as you are using Apache 2.4.x change it to
# onlineoffline tag - don't remove
Require all granted