前言:尝试为Plesk安装JXCore的Node Extension,我无法让它工作.给我一些错误,他们的支持不是回复电子邮件……
[IP ADDRESS] =真实IP,example.com =真实域
无论如何,我有我的nodejs应用程序并运行SSL证书.如果我去https://example.com:3000工作正常,这是我用于Node的端口. SSL证书加载所有绿色,一切都很好.
我正在使用Plesk 12.5,并且已经安装了Nginx. .conf文件位于/var/www/vhosts/[domain]/conf/Nginx.conf.
在顶部它说:
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
他们不是在开玩笑.对此文件进行任何更改几乎立即被覆盖.
server {
listen [IP ADDRESS]:443 ssl;
server_name example.com;
server_name www.example.com;
server_name ipv4.example.com;
ssl_certificate /usr/local/psa/var/certificates/cert-HREdQ9;
ssl_certificate_key /usr/local/psa/var/certificates/cert-HREdQ9;
ssl_client_certificate /usr/local/psa/var/certificates/cert-wpX6q1;
client_max_body_size 128m;
root "/var/www/vhosts/msgable.com/httpdocs";
access_log "/var/www/vhosts/system/example.com/logs/proxy_access_ssl_log";
error_log "/var/www/vhosts/system/example.com/logs/proxy_error_log";
location / {
proxy_pass https://[IP ADDRESS]:7081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location @fallback {
proxy_pass https://[IP ADDRESS]:7081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ ^/plesk-stat/ {
proxy_pass https://[IP ADDRESS]:7081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ ^/(.*\.(ac3|avi|bmp|bz2|css|cue|dat|doc|docx|dts|eot|exe|flv|gif|gz|htm|html|ico|img|iso|jpeg|jpg|js|mkv|mp3|mp4|mpeg|mpg|ogg|pdf|png|ppt|pptx|qt|rar|rm|svg|swf|tar|tgz|ttf|txt|wav|woff|woff2|xls|xlsx|zip))${
try_files $uri @fallback;
}
location ~ ^/(plesk-stat|webstat|webstat-ssl|ftpstat|anon_ftpstat|awstats-icon) {
proxy_pass https://74.208.65.63:7081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ ^/~(.+?)(/.*?\.PHP)(/.*)?${
alias /var/www/vhosts/example.com/web_users/$1/$2;
fastcgi_split_path_info ^((?U).+\.PHP)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass "unix:///var/www/vhosts/system/example.com/PHP-fpm.sock";
include /etc/Nginx/fastcgi.conf;
}
location ~ ^/~(.+?)(/.*)?${
proxy_pass https://[IP ADDRESS]:7081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location ~ \.PHP(/.*)?${
fastcgi_split_path_info ^((?U).+\.PHP)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass "unix:///var/www/vhosts/system/example.com/PHP-fpm.sock";
include /etc/Nginx/fastcgi.conf;
}
location ~ /${
index index.html index.cgi index.pl index.PHP index.xhtml index.htm index.shtml;
}
include "/var/www/vhosts/system/example.com/conf/vhost_Nginx.conf";
}
我不会包含HTTP(非ssl)内容,因为它是相同的信息.唯一的区别是端口是80,proxy_pass设置为7080.
你会在底部注意到它有:
include "/var/www/vhosts/system/example.com/conf/vhost_Nginx.conf";
location / {
proxy_pass https://[IP ADDRESS]:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
把它放在那里给了我一个:
Nginx: [emerg] duplicate location "/"
我也尝试在设置中使用Plesk的“附加Nginx指令”,但是我得到了同样的错误:
Nginx:[emerg]重复的位置“/”
有任何想法吗?我准备抛弃Plesk并调查AWS或其他……
我得出的结论是,a)你不能覆盖Plesk创建的Nginx confs,b)你不能直接更改conf文件.
所以基本上与Plesk的proxy_pass是不可能的.
编辑:
还尝试了上游方式,但是通过Plesk或通过vhost_Nginx.conf将Upstream指令添加到管理界面给了我一个错误,说“Nginx:[emerg]指令不允许在此处使用Upstream”.
编辑#2:
阅读这篇文章Nginx to address Nodejs app,添加在这里解释的内容没有任何作用.开始认为使用Plesk是不可能的.
ARG!没有Plesk的服务器上这么简单的任务!