我有一个子域的nging
php配置。我还安装了node 5
和pm2
我想知道如何修改配置以使test.domain.com
代理到节点端口8080或3000.我一直尝试few things但没有成功。
我希望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;
}
}
答案 0 :(得分:0)
尝试以下nginx配置。并将其放入/etc/nginx/servers
。您应该能够代理传递给节点服务器。确保节点服务器已启动并正在运行。
server {
listen 80;
server_name test.domain.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
}
}