簡體   English   中英

Nginx配置以node為domain.com和php在子文件夾中運行為domain.com/phptest

[英]nginx configuration to run node as domain.com and php in subfolder as domain.com/phptest

我能夠在端口8080上運行節點,並將其指向domain.com,但我想同時運行php。

示例配置如下:

proxy_buffering on;
proxy_buffer_size 1k;
proxy_buffers 24 4k;
proxy_busy_buffers_size 8k;
proxy_max_temp_file_size 2048m;
proxy_temp_file_write_size 32k;

server {
listen 80;
server_name domain.com;
location / {

         proxy_pass  http://domain.com:8080;
         proxy_redirect off;
         proxy_set_header        X-Forwarded-For $remote_addr;

         location ~* \.(html|css|jpg|gif|ico|js)$ {
                proxy_cache          cache;
                proxy_cache_key      $host$uri$is_args$args;
                proxy_cache_valid    200 301 302 30m;
                expires              30m;
                proxy_pass  http://domain.com:8080;
         }
    }
}

現在我想將domain.com/php作為php服務器運行,因此任何具有domain.com/php的請求都將處理php,而其他請求將在節點上工作。 可能嗎?

 server {
 listen 80;
 server_name www.domain.com;
 root /var/www/html/testphp/api;
 location / {
 proxy_pass  http://www.domain.com:8080;
 proxy_redirect off;
 proxy_set_header        X-Forwarded-For $remote_addr;
 location ~* \.(html|css|jpg|gif|ico|js)$ {
    proxy_cache          cache;
    proxy_cache_key      $host$uri$is_args$args;
    proxy_cache_valid    200 301 302 30m;
    expires              30m;
    proxy_pass  http://www.domain.com:8080;
    }
}

location  /api/ {
    alias /var/www/html/testphp/api/;
    try_files $uri $uri/ /api/index.php;
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        fastcgi_pass unix:/run/php/php5.6-fpm.sock;
        fastcgi_param   SCRIPT_FILENAME $request_filename;
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM