囧事-怎样禁止某个域名访问本VPS?
这事太囧了。我买了个VPS,架好站www.ykdh.com之后发现有个域名,http://kcp.capturesourcemedia.com/,夜指向本IP,并且可以成功访问。
但是http://kcp.capturesourcemedia.com/根本不是我的啊,我估计是原来这个站曾经用过这个VPS的IP,现在我用该IP后http://kcp.capturesourcemedia.com/并没有修正他的DNS造成的。
现在的囧事是,两个域名,www.ykdh.com和http://kcp.capturesourcemedia.com/都指向同一个IP并且都可以成功访问。
请问怎样禁止http://kcp.capturesourcemedia.com/访问本VPS? lnmp 里添加这个域名,收到这个域名以后返回404之类的 用空主机头,论坛搜索里搜空主机名头
回复 3# 的帖子
看了相关贴子https://bbs.vpser.net/redirect.php?fid=25&tid=6950&goto=nextoldset。尝试了相关的操作,没有成功。
现在有几个问题:
1,该nginx.conf 文件的路径是?
2,请说明下,到底是把哪些代码修改为目标代码?
3,需要重启NGINX不? nginx。conf路径自己找官网文档 lnmp.org/install.html 上面写的很清楚,每个程序的都有
肯定是替换掉nginx.conf里唯一的server { } 段
不重启怎么生效 不行啊
nginx.conf文件内容如下:
userwww www;
worker_processes 1;
error_log/home/wwwlogs/nginx_error.logcrit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zonecrawler$binary_remote_addr10m;
server
{
listen 80;
server_name www.ykdh.com;
index index.html index.htm index.php;
root/home/wwwroot;
location ~ .*\.(php|php5)?$
{
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log/home/wwwlogs/access.logaccess;
}
include vhost/*.conf;
}
修改为:
userwww www;
worker_processes 1;
error_log/home/wwwlogs/nginx_error.logcrit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zonecrawler$binary_remote_addr10m;
server {
listen 80 default;
return 500;
}
和:
userwww www;
worker_processes 1;
error_log/home/wwwlogs/nginx_error.logcrit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zonecrawler$binary_remote_addr10m;
server
{
listen 80;
listen 80 default;
return 500;
root/home/wwwroot;
location ~ .*\.(php|php5)?$
{
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location /status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log/home/wwwlogs/access.logaccess;
}
include vhost/*.conf;
}
都不行啊
重启之后无法访问。 我表示相当。。。userwww www;
worker_processes 1;
error_log/home/wwwlogs/nginx_error.logcrit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zonecrawler$binary_remote_addr10m;
server
{
listen 80 default;
return 500;
}
include vhost/*.conf;
}
然后 /usr/local/nginx/sbin/nginx -s reload ,不reload 永远不会生效。 你需要用ip来直接访问你的站点吗,不需要的话,就在nginx直接绑定你的域名就可以了
回复 7# 的帖子
这么做了以后,访问www.ykdh.com这个已经绑定了的主域名都500不知道怎么办。 原来的ykdh的虚拟主机都改成返回500的server {}段了 肯定不行了,需要你再加上ykdh的域名才行
没绑定的域名都返回500
回复 10# 的帖子
那请问该怎么加呢?帮人帮到底,麻烦像刚才那样贴出完整的代码,谢谢。 /root/vhost.sh 官网上http://lnmp.org/install.html有详细的说明自行阅读。:L
回复 12# 的帖子
哥,怪我,是我没说清楚。在安装LNMP的时候,已经绑定了www.ykdh.com到/home/wwwroot/了,并且可以成功访问。
现在的情况是,按照你在7楼给的代码,使用之后,连已经绑定了的www.ykdh.com都500。
那按照你在12楼的意思是,再重新添加一次www.ykdh.com并绑定至原目录?
页:
[1]