1

Recently I installed VESTACP and nginx, added domain name and everything is fine, I can access my website with domain but also when I type an IP address from server (http://11.11.11.11) I can access my website so is there any solution to avoid showing my ip address ?

Thank you guys

This is my nginx conf file:

    listen   11.11.3.171:80;
    server_name example.com www.example.com;
    error_log  /var/log/apache2/domains/example.com.error.log error;

    location / {
        proxy_pass      http://11.11.3.171:8080;
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
            root           /home/admin/web/example.com/public_html;
            access_log     /var/log/apache2/domains/example.com.log combined;
            access_log     /var/log/apache2/domains/example.com.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

    location /error/ {
        alias   /home/admin/web/example.com/document_errors/;
    }

    location @fallback {
        proxy_pass      http://11.11.3.171:8080;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include /home/admin/conf/web/nginx.example.com.conf*;
}

Apache conf file:

<VirtualHost 11.11.3.171:8080>

    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin info@example.com
    DocumentRoot /home/admin/web/example.com/public_html
    ScriptAlias /cgi-bin/ /home/admin/web/example.com/cgi-bin/
    Alias /vstats/ /home/admin/web/example.com/stats/
    Alias /error/ /home/admin/web/example.com/document_errors/
    #SuexecUserGroup admin admin
    CustomLog /var/log/apache2/domains/example.com.bytes bytes
    CustomLog /var/log/apache2/domains/example.com.log combined
    ErrorLog /var/log/apache2/domains/example.com.error.log
    <Directory /home/admin/web/example.com/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
        php_admin_value open_basedir /home/admin/web/example.com/public_html:/home/admin/tmp
        php_admin_value upload_tmp_dir /home/admin/tmp
        php_admin_value session.save_path /home/admin/tmp
    </Directory>
    <Directory /home/admin/web/example.com/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid admin admin
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID admin admin
    </IfModule>

    IncludeOptional /home/admin/conf/web/apache2.example.com.conf*

</VirtualHost>
Edgar
  • 17
  • 4

1 Answers1

0

As the Domain Name System is just a protocol to resolve (domain-)names to their IP adresses, you can not really hide your adresse.

But you can use nginx to answer to requests using the appropriate name only.

In your nginx.conf (or sites- config) check fot the listenand server_namedirective:

server {
    listen       80;
    server_name  yourserver.com www.yourserver.com;
    ...
}

In the Nginx configuration file, you are allowed to have multiple server "{}" blocks. Incoming requests are matched against the server_name directive - in a top to down fashion.

In the case of multiple server blocks, if the request is for a non-existent domain, then it will always be handled by the first server block.

If you want to block requests coming from any other (aka 'not catched by existing block') adresses, just add the following server block to catch them:

server {
    listen 80 default_server;
    server_name _;
    return 444;
}

Setting server_name to _ means 'default' or "match all". The response code 444, returns as "NO RESPONSE", a special nginx non-standard that closes the connection immediately.

bjoster
  • 4,423
  • 5
  • 22
  • 32