Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

How to preven entering of a naked IP to open a site?

General questions about VestaCP
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
VestaLover
Posts: 36
Joined: Thu Dec 05, 2013 10:55 am

Re: How to preven entering of a naked IP to open a site?
  • Quote

Post by VestaLover » Tue Jul 07, 2015 8:47 am

GreenUnicorn wrote:How to make it only a domain to load a site and naked IP to not load anything at all?

Also when there are lots of sites on a VPS how it decides which one to load?
I believe before it wasn't loading any particular site but the default one, but now seems to always load one of the sites.
1. I believe you can not do that. People can visit your site using IP address or domain. CMIIW
2. If your domain has been added to the vestacp configuration it will be loaded automatically, if not, then the default page will be served to the visitor.

Actually I don't really get into your question, but hopefully my answer works for you.
Top

OCPZend
Posts: 3
Joined: Sun Jun 07, 2015 9:51 am

Re: How to preven entering of a naked IP to open a site?
  • Quote

Post by OCPZend » Tue Jul 07, 2015 10:33 am

<?php
if(preg_match("#^[0-9\.$]+#",$_SERVER['REMOTE_ADDR']){
die();
/*
Or
header('location:http://www.url.com');
*/
}
?>
You can achive this with php, and "default domain'

another approach is via .htaccess
http://stackoverflow.com/questions/1055 ... www-domain

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^111\.111\.111\.111 [OR]
RewriteCond %{HTTP_HOST} ^222\.222\.222\.222
RewriteRule (.*) http://www.example.me/$1 [R=301]
Top

Felix
Posts: 134
Joined: Tue Aug 04, 2015 7:15 pm

Os: Ubuntu 15x
Web: apache + nginx
Re: How to preven entering of a naked IP to open a site?
  • Quote

Post by Felix » Fri Aug 07, 2015 9:46 pm

Apache starts to load site configuration from the file /etc/apache2/conf.d/vesta.conf
This file contains commands to include more configuration files.

Since Apache can't determine the web site to load from the url, because the user typed the IP address instead, it loads the first site it finds in the above config files.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: How to preven entering of a naked IP to open a site?
  • Quote

Post by skurudo » Wed Aug 12, 2015 7:53 am

Felix wrote: Since Apache can't determine the web site to load from the url, because the user typed the IP address instead, it loads the first site it finds in the above config files.
Sure things, and default.domain it's nice thing for those, who typed IP.
Top


Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password