在 nginx 中复制 UserDir Apache 功能

mma*_*tax 2 nginx

我是 nginx 菜鸟,正在寻求帮助(我的 nginx 配置如下)。我试图将 nginx 放在当前使用 Apache 的 PHP 应用程序前面。

我的“/”位置工作正常。Nginx 为静态文件提供服务,并为动态内容代理到 apache。

我现在正在尝试使“UserDir”功能正常工作。我需要http://example.com/~mmattax/使用 /home/mmattax/public_html 作为文档根目录和代理到 apache 的动态内容。我在下面的尝试似乎将所有内容都代理到了 apache;nginx 似乎没有使用正确的文档根目录。

我也在寻找有关下面配置的任何提示。谢谢。

location ~ ^/~(.+?)(/.*)?$ {
    root /home/$1/public_html;
    index  index.php;
    autoindex on;
    try_files $uri $uri/ @proxy;
}

location / {
    root  /home/myapp/www;
    index index.php;
    try_files $uri $uri/ @proxy;
}

location @proxy {
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect off;
}

location ~ \.php$ {
    proxy_pass      http://127.0.0.1:8080;
    proxy_redirect  off;
}
Run Code Online (Sandbox Code Playgroud)

use*_*517 6

我在nginx wiki上找到了这个

location ~ ^/~(.+?)(/.*)?$ {
 alias /home/$1/public_html$2;
 index  index.html index.htm;
 autoindex on;
}
Run Code Online (Sandbox Code Playgroud)