【发布时间】:2013-05-06 07:52:38
【问题描述】:
我使用 ubuntu x64 服务器和 nginx 作为网络服务器。
在我公司,我们配置了 Intranet(本地)dns 服务器,这样当您输入 domain1.com 时,它会直接进入定义的 LAN ip 地址。
我们需要对位于同一台服务器上的 domain2.com 进行全局访问。当我们为 domain2.com 开启全局访问时,出现如下问题:
如您所知,任何人都可以检测到 domain2.com(我们的服务器)的 IP 地址。
问题是,当您直接使用服务器的全局 IP 地址访问时,服务器会自动打开 domain1.com,必须限制全局访问。这是 domain1.com 的 nginx 配置:
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 the calls to 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;
}
}
如何使 domain1.com 只用于局域网(限制全局访问)?
【问题讨论】:
标签: ubuntu web nginx ubuntu-12.04