Nginx + php is configured with an IP address to access the domain name, but not the domain name.

Source: Internet
Author: User
Tags sendfile
Why can't I use localhost: 81 or 127.0.0.1: 81 in Nginx to access the domain name with the available settings? This is nginx. conf code: {code ...} my C: WindowsSystem32driversetchosts file: {code ...} why can't I use localhost: 81 or 127.0.0.1: 81 in Nginx to access the domain name with the available settings?
This is the nginx. conf code:

#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;        }    }    }

My C: \ Windows \ System32 \ drivers \ etc \ hosts file:

# 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 inpidual 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 inpidual# 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

Reply content:

Why can't I use localhost: 81 or 127.0.0.1: 81 in Nginx to access the domain name with the available settings?
This is the nginx. conf code:

#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;        }    }    }

My C: \ Windows \ System32 \ drivers \ etc \ hosts file:

# 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 inpidual 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 inpidual# 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

In your hosts, yes127.0.0.1 www.test.com
Access domain name is now127.0.0.1:80Port. The default value is80
But what is enabled on your server port?81

Access www.test.com: 81

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.