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”语句移动到服务器块中,以便它由新的位置块继承。 –