1
這裏是我的nginx.conf供應來example.com
與/srv/phabricator/phabricator/webroot/index.php
的任何請求。我想改變功能,如果請求進入example.com/test
則提供/home/phragile/public/index.php
。如何nginx的請求重定向到不同的路徑
daemon off;
error_log stderr info;
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 4096;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
client_max_body_size 200M;
client_body_buffer_size 200M;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket_pool {
ip_hash;
server 127.0.0.1:22280;
}
server {
listen *:80;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /srv/phabricator/phabricator/webroot;
try_files $uri $uri/ /index.php;
location /.well-known/ {
root /srv/letsencrypt-webroot;
}
location/{
index index.php;
if (!-f $request_filename)
{
rewrite ^/(.*)$ /index.php?__path__=/$1 last;
break;
}
}
location /index.php {
include /app/fastcgi.conf;
fastcgi_param PATH "/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/bin";
fastcgi_pass 127.0.0.1:9000;
}
location = /ws/ {
proxy_pass http://websocket_pool;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 999999999;
}
}
}
我曾嘗試以下,但它不工作:
location /test {
root /home/phragile/public;
}
有人能告訴我需要在.conf文件添加什麼?
這個工作時,我嘗試了下面的URI:'http:// code.baqar.xgrid/test/index.php' 我需要改變什麼才能使它只使用'http://代碼。 baqar.xgrid/test /' –
將「index index.php」語句移動到服務器塊中,以便它由新的位置塊繼承。 –