我nginx 使用localhost:81或者127.0.0.1:81 可以访问 可用设置的域名访问不到这是为什么?
这是nginx.conf 的代码:
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] $request ' # '$status $body_bytes_sent $http_referer ' # '$http_user_agent $http_x_forwarded_for'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 81; server_name www.test.com; root d:/src/web/runroot; error_page 404 /404.html; error_page 500 502 503 504 /50x.html; if ($remote_addr !~ 123.125.169.174) { # rewrite ^ http://lavaradio.wix.com/lavaradio redirect; } rewrite ^/api/(.*?)\.json$ /index.php?route=api/$1&_of=json break; if (!-f $request_filename) { rewrite ^/(.*?)$ /index.php?route=$1 last; } location /index.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } } }
我的c:\windows\system32\drivers\etc\hosts文件:
# copyright (c) 1993-2009 microsoft corp.## this is a sample hosts file used by microsoft tcp/ip for windows.## this file contains the mappings of ip addresses to host names. each# entry should be kept on an individual line. the ip address should# be placed in the first column followed by the corresponding host name.# the ip address and the host name should be separated by at least one# space.## additionally, comments (such as these) may be inserted on individual# lines or following the machine name denoted by a '#' symbol.## for example:## 102.54.94.97 rhino.acme.com # source server# 38.25.63.10 x.acme.com # x client host# localhost name resolution is handled within dns itself.127.0.0.1 www.test.com
回复内容: 我nginx 使用localhost:81或者127.0.0.1:81 可以访问 可用设置的域名访问不到这是为什么?
这是nginx.conf 的代码:
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] $request ' # '$status $body_bytes_sent $http_referer ' # '$http_user_agent $http_x_forwarded_for'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 81; server_name www.test.com; root d:/src/web/runroot; error_page 404 /404.html; error_page 500 502 503 504 /50x.html; if ($remote_addr !~ 123.125.169.174) { # rewrite ^ http://lavaradio.wix.com/lavaradio redirect; } rewrite ^/api/(.*?)\.json$ /index.php?route=api/$1&_of=json break; if (!-f $request_filename) { rewrite ^/(.*?)$ /index.php?route=$1 last; } location /index.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } } }
我的c:\windows\system32\drivers\etc\hosts文件:
# copyright (c) 1993-2009 microsoft corp.## this is a sample hosts file used by microsoft tcp/ip for windows.## this file contains the mappings of ip addresses to host names. each# entry should be kept on an individual line. the ip address should# be placed in the first column followed by the corresponding host name.# the ip address and the host name should be separated by at least one# space.## additionally, comments (such as these) may be inserted on individual# lines or following the machine name denoted by a '#' symbol.## for example:## 102.54.94.97 rhino.acme.com # source server# 38.25.63.10 x.acme.com # x client host# localhost name resolution is handled within dns itself.127.0.0.1 www.test.com
你hosts中是 127.0.0.1 www.test.com
访问域名就到了 127.0.0.1:80 端口了,默认是80
但是你的服务器端口开的是81
访问 www.test.com:81