簡體   English   中英

更改nginx配置以適應nodejs怎么辦?

[英]Changing nginx config to accommodate nodejs how to?

我有一個子網域的nging php配置。 我也安裝了node 5pm2

我想知道如何修改配置以將test.domain.com代理設置為節點端口8080或3000。我一直在嘗試一些成功的嘗試。

我希望test.domain.com指向節點服務器,而不是/usr/share/nginx/html/test

server {
    listen      80;
    server_name test.domain.com;
    set         $root_path '/usr/share/nginx/html/test';
    root        $root_path;

    access_log  /var/log/nginx/test-access.log;
    error_log   /var/log/nginx/test-error.log error;

    index index.php index.html index.htm;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {
        # try_files    $uri =404;

        fastcgi_index  index.php;
        fastcgi_pass   127.0.0.1:9000;

        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param APPLICATION_ENV "testing";
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}

嘗試以下nginx配置。 並將其放在/etc/nginx/servers 您應該能夠代理傳遞給節點服務器。 確保節點服務器已啟動並正在運行。

server {
    listen      80;
    server_name test.domain.com;  

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
    }
}

暫無
暫無

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

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