2016-03-28 91 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