使用englintron托管多个站点nginx

时间:2019-02-27 10:23:47

标签: node.js nginx reverse-proxy

我在Cpanel VPS上安装了Nginx。我正在使用Engintron,它会自动执行所有配置文件。它可以使用HTTP 1.1在我所有的域中正常工作,并且不需要任何额外的配置。我试图在我的一个域上使用Http 2托管节点js应用程序。我成功制作了反向代理,因此我的应用可以使用带有以下代码的nginx自定义规则来侦听端口6555

if ($host ~ "system.easyschools.org") {
set $PROXY_SCHEME "http";
set $PROXY_DOMAIN_OR_IP "system.easyschools.org";
set $PROXY_TO_PORT 6555; }

我现在只能通过端口访问它。我想从URL中删除端口,以便用户无需它即可访问它。我试图将以下代码放入default.conf

服务器{

listen 80 default_server;
#listen [::]:80 default_server;

server_name localhost;


# deny all; # DO NOT REMOVE OR CHANGE THIS LINE - Used when Engintron is disabled to block Nginx from becoming an open proxy

# Set the port for HTTP proxying
set $PROXY_TO_PORT 8080;

include common_http.conf;

location = /nginx_status {
    stub_status;
    access_log off;
    log_not_found off;
    # Uncomment the following 2 lines to make the Nginx status page private.
    # If you do this and you have Munin installed, graphs for Nginx will stop working.
    #allow 127.0.0.1;
    #deny all;
}

location = /whm-server-status {
    proxy_pass http://127.0.0.1:8080; # Apache Status Page
    # Comment the following 2 lines to make the Apache status page public
    allow 127.0.0.1;
    deny all;
}

}}

 server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name system.easyschools.org  www.system.easyschools.org;
ssl_certificate /home/rayes/ssl/certs/system_easyschools_org_a3044_b704f_1558569599_54ce16d2dea6604346f0a5f27d82e140.crt;
ssl_certificate_key /home/rayes/ssl/keys/a3044_b704f_5aa8e3c7d1527dc1355e497884c30790.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:6555/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;

proxy_read_timeout 5m; }

现在,我在nginx错误日志中保持此错误

  

0.0.0.0:443上的服务器名称“ system.easyschools.org”发生冲突,已忽略

您可以测试错误thourgh“ https://system.easyschools.org:6555”&“ https://system.easyschools.org”,该错误获得502网关。

0 个答案:

没有答案