VPS侦探论坛

 找回密码
 注册
查看: 9816|回复: 12

囧事-怎样禁止某个域名访问本VPS?

[复制链接]
发表于 2012-4-22 17:43:07 | 显示全部楼层 |阅读模式

这事太囧了。

我买了个VPS,架好站www.ykdh.com之后发现有个域名,http://kcp.capturesourcemedia.com/,夜指向本IP,并且可以成功访问。

但是http://kcp.capturesourcemedia.com/根本不是我的啊,我估计是原来这个站曾经用过这个VPS的IP,现在我用该IP后http://kcp.capturesourcemedia.com/并没有修正他的DNS造成的。


现在的囧事是,两个域名,www.ykdh.comhttp://kcp.capturesourcemedia.com/都指向同一个IP并且都可以成功访问。

请问怎样禁止http://kcp.capturesourcemedia.com/访问本VPS?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-4-23 22:36:52 | 显示全部楼层


lnmp 里添加这个域名,收到这个域名以后返回404之类的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-4-24 08:20:07 | 显示全部楼层

用空主机头,论坛搜索里搜空主机名头
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-4-28 15:20:56 | 显示全部楼层

回复 3# 的帖子




看了相关贴子https://bbs.vpser.net/redirect.p ... amp;goto=nextoldset

尝试了相关的操作,没有成功。

现在有几个问题:
1,该nginx.conf 文件的路径是?
2,请说明下,到底是把哪些代码修改为目标代码?
3,需要重启NGINX不?
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-4-28 15:31:21 | 显示全部楼层

nginx。conf路径自己找官网文档 lnmp.org/install.html 上面写的很清楚,每个程序的都有

肯定是替换掉nginx.conf里唯一的server { } 段

不重启怎么生效

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2012-4-28 16:28:33 | 显示全部楼层

不行啊
nginx.conf文件内容如下:
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 50m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 server_name www.ykdh.com;
  43.                 index index.html index.htm index.php;
  44.                 root  /home/wwwroot;

  45.                 location ~ .*\.(php|php5)?$
  46.                         {
  47.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  48.                                 fastcgi_index index.php;
  49.                                 include fcgi.conf;
  50.                         }

  51.                 location /status {
  52.                         stub_status on;
  53.                         access_log   off;
  54.                 }

  55.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  56.                         {
  57.                                 expires      30d;
  58.                         }

  59.                 location ~ .*\.(js|css)?$
  60.                         {
  61.                                 expires      12h;
  62.                         }

  63.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  64.              '$status $body_bytes_sent "$http_referer" '
  65.              '"$http_user_agent" $http_x_forwarded_for';
  66.                 access_log  /home/wwwlogs/access.log  access;
  67.         }
  68. include vhost/*.conf;
  69. }
复制代码

修改为:
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 50m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server {
  40. listen 80 default;
  41. return 500;
  42. }
复制代码


和:
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 50m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen       80;
  42.                 listen 80 default;
  43. return 500;
  44.                 root  /home/wwwroot;

  45.                 location ~ .*\.(php|php5)?$
  46.                         {
  47.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  48.                                 fastcgi_index index.php;
  49.                                 include fcgi.conf;
  50.                         }

  51.                 location /status {
  52.                         stub_status on;
  53.                         access_log   off;
  54.                 }

  55.                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  56.                         {
  57.                                 expires      30d;
  58.                         }

  59.                 location ~ .*\.(js|css)?$
  60.                         {
  61.                                 expires      12h;
  62.                         }

  63.                 log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  64.              '$status $body_bytes_sent "$http_referer" '
  65.              '"$http_user_agent" $http_x_forwarded_for';
  66.                 access_log  /home/wwwlogs/access.log  access;
  67.         }
  68. include vhost/*.conf;
  69. }
复制代码


都不行啊

重启之后无法访问。
发表于 2012-4-28 17:57:08 | 显示全部楼层

我表示相当。。。
  1. user  www www;

  2. worker_processes 1;

  3. error_log  /home/wwwlogs/nginx_error.log  crit;

  4. pid        /usr/local/nginx/logs/nginx.pid;

  5. #Specifies the value for maximum file descriptors that can be opened by this process.
  6. worker_rlimit_nofile 51200;

  7. events
  8.         {
  9.                 use epoll;
  10.                 worker_connections 51200;
  11.         }

  12. http
  13.         {
  14.                 include       mime.types;
  15.                 default_type  application/octet-stream;

  16.                 server_names_hash_bucket_size 128;
  17.                 client_header_buffer_size 32k;
  18.                 large_client_header_buffers 4 32k;
  19.                 client_max_body_size 50m;

  20.                 sendfile on;
  21.                 tcp_nopush     on;

  22.                 keepalive_timeout 60;

  23.                 tcp_nodelay on;

  24.                 fastcgi_connect_timeout 300;
  25.                 fastcgi_send_timeout 300;
  26.                 fastcgi_read_timeout 300;
  27.                 fastcgi_buffer_size 64k;
  28.                 fastcgi_buffers 4 64k;
  29.                 fastcgi_busy_buffers_size 128k;
  30.                 fastcgi_temp_file_write_size 256k;

  31.                 gzip on;
  32.                 gzip_min_length  1k;
  33.                 gzip_buffers     4 16k;
  34.                 gzip_http_version 1.0;
  35.                 gzip_comp_level 2;
  36.                 gzip_types       text/plain application/x-javascript text/css application/xml;
  37.                 gzip_vary on;

  38.                 #limit_zone  crawler  $binary_remote_addr  10m;

  39. server
  40.         {
  41.                 listen 80 default;
  42.                 return 500;
  43.         }
  44. include vhost/*.conf;
  45. }
复制代码

然后 /usr/local/nginx/sbin/nginx -s reload ,不reload 永远不会生效。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-4-29 15:39:48 | 显示全部楼层

你需要用ip来直接访问你的站点吗,不需要的话,就在nginx直接绑定你的域名就可以了
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-4-30 21:54:05 | 显示全部楼层

回复 7# 的帖子


这么做了以后,访问www.ykdh.com这个已经绑定了的主域名都500

不知道怎么办。
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-4-30 22:06:40 | 显示全部楼层



原来的ykdh的虚拟主机都改成返回500的server {}段了 肯定不行了,需要你再加上ykdh的域名才行

没绑定的域名都返回500
 楼主| 发表于 2012-5-1 00:03:32 | 显示全部楼层

回复 10# 的帖子


那请问该怎么加呢?

帮人帮到底,麻烦像刚才那样贴出完整的代码,谢谢。
发表于 2012-5-1 10:08:36 | 显示全部楼层

/root/vhost.sh 官网上http://lnmp.org/install.html有详细的说明自行阅读。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-5-1 11:39:12 | 显示全部楼层

回复 12# 的帖子

哥,怪我,是我没说清楚。

在安装LNMP的时候,已经绑定了www.ykdh.com到/home/wwwroot/了,并且可以成功访问。

现在的情况是,按照你在7楼给的代码,使用之后,连已经绑定了的www.ykdh.com都500。

那按照你在12楼的意思是,再重新添加一次www.ykdh.com并绑定至原目录?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-22 21:31 , Processed in 0.029395 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表