在项目中有时一个完整的项目需要整合在另外一个项目中,作为一个子模块存在

    如有两个项目 help 、 blog ,根目录分别为/alidata/www/help.abx.net, /alidata/www/blog.abx.net

    若要用域名http://test.abx.net/help访问help,用http://test.abx.net/blog访问blog项目,可参考如下配置

    1. server
    2. {
    3. listen 80;
    4. server_name test.abx.net;
    5. index home.html index.htm index.php default.html default.htm default.php;
    6. root /alidata/www/test.abx.net/dist;
    7. #error_page 404 /404.html;
    8. location /help {
    9. root /alidata/www/help.abx.net;
    10. if (!-e $request_filename) {
    11. rewrite ^(.*)$ /help/index.php$1 last;
    12. }
    13. location ~ \.php(\/.*)*$ {
    14. fastcgi_split_path_info ^(.+?.php)(/.*)$;
    15. fastcgi_pass unix:/tmp/php-cgi.sock;
    16. fastcgi_index index.php;
    17. fastcgi_param SCRIPT_FILENAME /alidata/www/help.abx.net$fastcgi_script_name;
    18. include fastcgi_params;
    19. }
    20. access_log /alidata/log/nginx/access/help.abx.net.log;
    21. }
    22. location /blog {
    23. root /alidata/www/blog.abx.net;
    24. try_files $uri $uri/ /blog/index.php?$args;
    25. include enable-php.conf;
    26. access_log /alidata/log/nginx/access/blog.abx.net.log;
    27. }
    28. location /api/ {
    29. proxy_pass https://localhost:3010;
    30. }
    31. # Deny access to PHP files in specific directory
    32. location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
    33. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    34. {
    35. expires 30d;
    36. }
    37. location ~ .*\.(js|css)?$
    38. {
    39. expires 12h;
    40. }
    41. location ~ /.well-known {
    42. allow all;
    43. }
    44. location ~ /\.
    45. {
    46. deny all;
    47. }
    48. access_log /alidata/log/nginx/access/test.abx.net.log;
    49. }