使用nginx重定向重定向到Windows中的localhost

时间:2015-07-28 06:14:51

标签: windows apache redirect nginx

我正在尝试通过其配置文件和启用网站的文件夹中的文件将我的dns重定向到nginx, 但它总是重定向到nginx主页,显示'欢迎使用nginx!'。

我的配置文件包括:

NGINX.CONF

 user  www-data www-data;
    worker_processes  4;

    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;

    pid        var/run/nginx.pid;


    events {
        worker_connections  1024;
    }


    http {
        include       mime.types;
        default_type  application/octet-stream;
        include /conf/*.conf;
        include /conf/sites-enabled/*;

    #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;
    tcp_nodelay    on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    types_hash_max_size 2048;
    gzip  on;
    gzip_disable    "msie6";

    server {
        listen       80;
        server_name  fe.paytm.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {`enter code here`
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    }

在启用网站的文件夹中配置文件

 server {  
     server_name   my.domain.com; 
      root C:/Users/some/absolute-path/public;
      index index.html index.htm; 

     access_log /var/log/nginx/my-domain.access.log; 
      error_log  /var/log/nginx/my-domain.error.log; 
      underscores_in_headers on; 
      location /   {  
         root C:/Users/some/absolute-path/public;      
         proxy_pass http://localhost:8997;
      }
    }

ip的主机条目也已完成:

 127.0.0.1  my.domain.com

我错过了什么或做错了

1 个答案:

答案 0 :(得分:0)

您忘记在配置中添加listen 80。由于哪个nginx使用default.conf并显示“欢迎使用nginx!” 更新的配置如下所示:

server {  
  listen 80;
  server_name   my.domain.com; 
  root C:/Users/some/absolute-path/public;
  index index.html index.htm; 

  access_log /var/log/nginx/my-domain.access.log; 
  error_log  /var/log/nginx/my-domain.error.log; 
  underscores_in_headers on; 
  location /   {  
     root C:/Users/some/absolute-path/public;      
     proxy_pass http://localhost:8997;
  }
}