Subdomain with port number in Ubuntu 12.04 (Precise Pangolin) - subdomain

I have created subdomain in my DNS server. How can I set each subdomain so that it only accepts connections via a particular port?
For example: ftp.example.com → only accepts connections that come from port 21

You can set port restrictions using iptables.
You can also set port restrictions on the server itself and it depends on your server architecture. If you're running Apache, then you should take a look at defining a virtual host (vhost).
Just for illustration sake:
<VirtualHost *:21>
ServerAdmin webmaster#example.com
ServerName ftp.example.com
# Index + Directory root
DirectoryIndex index.php | index.html
DocumentRoot /var/www/path/to/site
</VirtualHost>
See that "*:21" - that's the port number.
Generally speaking, ftp.example.com would probably still redirect to your server's root directory.

Related

apache2 not opening index.html (404 Not Found)

I had several virtualhosts running with wordpress before. I uninstalled Wordpress to use my own website (HTML and CSS) but now I get an error "404 not found" saying "Not Found -
The requested URL was not found on this server." Can someone tell my why it is not opening the index.html file or where the problem could be found?
Here is my VirtualHost:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin jw.webmaster#domain.com
DocumentRoot /var/www/domain.com/public
ServerName domain.com
ServerAlias domain.com
DirectoryIndex index.html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/domaincom_error.log
CustomLog ${APACHE_LOG_DIR}/domaincom_access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

How to set up Masked Redirect with Google Cloud VM instances

I have a VM with multiple apps. for example:
32.32.32.01/app1
32.32.32.01/app2
32.32.32.01/app3
I have a domain name from namecheap and I want it to use it only for app1.
so www.mydomain.com should take me to 32.32.32.01/app1.
I created URL Redirect Records on namecheap for both aliases (www and #) but it is not working.
Do I have to also do some configuration at the google cloud side?
You need enter via ssh to the VM, you also need a Apache http server, and create a site: ex:
cd /etc/apache2/sites-available
sudo cp 000-default.conf siteName.conf
sudo nano siteName.conf
Add a configuration (i dont remember the exact config, but this can give you a idea of the file content)
<VirtualHost *:80>
ServerAdmin mail#server.co
ServerName domain.co
ServerAlias www.domain.co
DocumentRoot /var/www/site
...
Save the file and restart apache
sudo a2ensite siteName
sudo service apache2 reload

Apache2 webserver ubuntu 16.04 not allowing any page besides index.html

I'm attempting to add multiple html pages to my website.
I've pasted the files into /var/www/html which is what my virtual hosts file is pointing to. However, whenever I try to navigate to another html page such as domain.com/page.html it fails to find anything.
I feel like I'm missing a setting or something with apache2 that is preventing me from accessing anything but the index.html. I've checked to insure the files are in the correct directory. I hope someone has some idea whats going on as I'm a bit lost.
heres the virtual host file;
<VirtualHost 72.222.165.39:7777>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly
ServerName www.birnbaumdesign.com
ServerAlias *.birnbaumdesign.com
ServerAdmin royce.birnbaum#gmail.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

How to put wildcard entry into /etc/hosts?

I recently wanted to point all subdomains for a test domain, let's say example.com to the localhost. Is there a way to point all requests on *.example.com to resolve to 127.0.0.1
It happens that /etc/hosts file doesn't support wild card entries.
You'll have to use other services like dnsmasq. To enable it in dnsmasq, just edit dnsmasq.conf and add the following line:
address=/example.com/127.0.0.1
use dnsmasq
Assuming that you're using a Debian-based dist(ubuntu, mint..), check if it's installed with
(sudo) systemctl status dnsmasq
If it is just disabled, start it with
(sudo) systemctl start dnsmasq
If you have to install it, write
(sudo) apt-get install dnsmasq
To define domains to resolve edit /etc/dnsmasq.conf like this.
address=/example.com/127.0.0.1
to resolve *.example.com
! You must reload dnsmasq to take effect for the changes !
systemctl reload dnsmasq
Here is the configuration for those trying to accomplish the original goal (wildcards all pointing to same codebase -- install nothing, dev environment ie, XAMPP)
hosts file (add an entry)
file: /etc/hosts (non-windows)
127.0.0.1 example.local
httpd.conf configuration (enable vhosts)
file: /XAMPP/etc/httpd.conf
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
httpd-vhosts.conf configuration
file: XAMPP/etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin admin#example.local
DocumentRoot "/path_to_XAMPP/htdocs"
ServerName example.local
ServerAlias *.example.local
# SetEnv APP_ENVIRONMENT development
# ErrorLog "logs/example.local-error_log"
# CustomLog "logs/example.local-access_log" common
</VirtualHost>
restart apache
create pac file:
save as whatever.pac wherever you want to and then load the file in the browser's network>proxy>auto_configuration settings (reload if you alter this)
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*example.local")) {
return "PROXY example.local";
}
return "DIRECT";
}

How to rectify this virtualhost setup on Wamp?

Could anyone please help me with setting up this virtual host on my WAMP server?
I have read through several posts and blogs online and unable to get this set up.
I followed the procedure suggested here: http://www.ruifeio.com/2011/01/30/setting-up-virtual-hosts-on-wampserver/
When I do the above, my server hangs up. Presently I added the following to my C:/windows/system32/drivers/etc/hosts file
127.0.0.1 tsg.local
And I changed my httpd.conf Apache config file with Listen 90 since I am using Port 90
Plus, removed # tag as suggested in the above tutorial.
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
I also added the following to my httpd-vhosts.conf
<VirtualHost *:90>
ServerAdmin webmaster#localhost
DocumentRoot “C:\wamp\www\tsg\”
ServerName tsg.local
ErrorLog “C:\wamp\www\logs\tsg.log”
CustomLog “C:/wamp/www/logs/common.log” common
</VirtualHost>
And changed: NameVirtualHost *:80 to NameVirtualHost *:90
Thanks for helping out in advance!
If your server will start fine with the Virtual Host block removed, try fixing your quotes. It looks like you have some "magic quotes" instead of straight quotes - likely from copy and pasting from the tutorial. Try this instead:
<VirtualHost *:90>
ServerAdmin webmaster#localhost
DocumentRoot "C:\wamp\www\tsg\"
ServerName tsg.local
ErrorLog "C:\wamp\www\logs\tsg.log"
CustomLog "C:/wamp/www/logs/common.log" common
</VirtualHost>
You also might want to pick a more standard port to listen on, 8080 or 8888 rather than 90 if 80 is not an option.