2016-03-28 87 views
0

我得nginx的和proxy_pass有点小问题我的VPS,配置是这样的:的Nginx和proxy_pass IP

server { 

    listen 8080; 
    root /var/www/; 
    index index.php; 

    location ~ \.php { 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass wordpress; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_param QUERY_STRING  $query_string; 
      include fastcgi_params; 
    } 

}

server { 
    listen 80; 
    root /var/www; 
    index index.html; 

    location ~ ^/mihal { 
      proxy_pass http://127.0.0.1:8080; 
    } 

    location ~ \.php { 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass wordpress; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      fastcgi_param QUERY_STRING  $query_string; 
      include fastcgi_params; 
    } 

}

,每次我试图让http://serverdomanin.com/mihal我已被重定向到http://127.0.0.1/mihal ... 我应该适度地正确使用此配置? (在/ mihal /下是wordpress实例)。 非常感谢您的帮助!

回答

1

重定向由端口8080上运行的服务生成,端口8080不知道名称serverdomain.com

您可以使用proxy_redirect指令重写重定向。

试试这个:

location ~ ^/mihal { 
    proxy_pass http://127.0.0.1:8080; 
    proxy_redirect http://localhost/ http://$host/; 
    proxy_redirect http://localhost:8080/ http://$host/; 
} 

详见this document