ubuntu - NginX access configuration -


i'm using ubuntu x64 server nginx webserver.

in company, configured intranet (local) dns server that, when enter domain1.com, goes directly defined lan ip adress.

we need global access domain2.com, located in same server. when open global access domain2.com, occurred following problem:

as know, can detect ip adress of domain2.com (our server).

the problem is, when access directly using server's global ip adress, server opens automatically domain1.com must restricted global access. here nginx config of domain1.com:

server { set $host_path "/var/www/domain1";  server_name domain1.com;  root $host_path; set $yii_bootstrap "index.php";  client_max_body_size 2000m; client_body_buffer_size 1024k;  listen       80;      charset utf-8;     index index.php index.html;  access_log  /var/access_log; error_log /var/error_log;  location ~ /(protected|framework|nbproject) {         deny all;         access_log off;         log_not_found off;     }      location / {         try_files $uri $uri/ /index.php?$args;     }      location ~ \.php$ {         fastcgi_split_path_info  ^(.+\.php)(.*)$;         #let yii catch calls unexising php files         set $fsn /$yii_bootstrap;         if (-f $document_root$fastcgi_script_name){             set $fsn $fastcgi_script_name;         }         fastcgi_pass unix:/var/run/php5-fpm.sock;         fastcgi_index index.php;         fastcgi_param script_filename $document_root$fastcgi_script_name;         include fastcgi_params;     }      location ~ /\.ht {         deny  all;     }   } 

how make domain1.com lan (restrict global access)?

if nginx serving request missing hostname , none of virtual servers has default_server parameter in listen directive, uses first virtual server finds. in case domain1.com. should change listen directive of domain2.com to:

listen 80 default_server; 

this way when uses ip address without hostname, served domain2.com content.

if want strictly require hostname , return 404 requests not specify it, can make new server clause:

server {     listen 80 default_server;     return 404; } 

there possible solution: if understood correctly, server has 2 ips: internal , external. if true, can change listen directive of domain1.com config listen 10.1.0.1:80; 10.1.0.1 internal ip address. way domain1.com reachable lan.


Comments