Javascript 更改nginx配置以适应nodejs如何?
我有一个子域的Javascript 更改nginx配置以适应nodejs如何?,javascript,node.js,nginx,proxy,Javascript,Node.js,Nginx,Proxy,我有一个子域的ngingphp配置。我还安装了node 5和pm2 我想知道如何修改配置以使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/shar
nging
php配置。我还安装了node 5
和pm2
我想知道如何修改配置以使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;
}
}