0

我使用了以下链接上的说明:

“通过 7 个简单步骤托管 Clojure Web 应用程序”

我知道 uberjar 可以工作,因为我在我的开发机器和 VPS 上都对其进行了测试。

只是Nginx好像找不到。我怀疑它与此站点代码有关:

# Web sockets
location /chsk {
proxy_pass http://backend/chsk;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

...但我不知道如何纠正它...感谢您的帮助!

另一件事:在站点文件的“上游后端”上,我尝试了 127.0.0.1:3000 和 0.0.0.0:3000 都没有成功。

这是默认站点配置:

server {
# Replace this port with the right one for your requirements
listen [::]:80 ipv6only=off;

# Multiple hostnames separated by spaces.  Replace these as well.
server_name clmitchell.net www.clmitchell.net main.clmitchell.net
books.clmitchell.net dna.clmitchell.net help.clmitchell.net
history.clmitchell.net svcs.clmitchell.net;
server_name_in_redirect off;

root /data/nginx/www/$host;

error_page 401 /error/401.shtml;
error_page 402 /error/402.shtml;
error_page 403 /error/403.shtml;
error_page 404 /error/404.shtml;
error_page 500 501 502 503 504 /error/500.shtml;

location ^~ /error/ {
  internal;
  root /data/nginx/www/www.clmitchell.net;
}


access_log /var/log/nginx/$host-access.log;
error_log /var/log/nginx/error.log;

index index.php index.html index.htm default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
      try_files $uri $uri/ /index.php?$args;
}

# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
  access_log off;
  expires max;
}

location ~ \.php$ {
  try_files $uri =404;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  include fastcgi_params;
}

location ~ \.scm$ {
  include fastcgi_params;
  fastcgi_intercept_errors on;
  # By all means use a different server for the fcgi processes if you need to
  fastcgi_pass  127.0.0.1:9981;
}

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

我从服务器名称列表中删除了 history.clmitchell.net。

这是当前的历史站点配置:

upstream backend {
   server 104.131.29.212:3000 fail_timeout=0;
}

server{
  listen [::]:80 ipv6only=off;
  server_name localhost history.clmitchell.net;

  access_log /var/log/hist_access.log;
  error_log /var/log/hist_error.log;

  root /var//resources/public;

  # Web sockets
  location /chsk {
    proxy_pass http://backend/chsk;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }

  # Static assets
  location / {
    try_files $uri @backend;
  }

  # The backend server
  location @backend {
    proxy_pass http://backend;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;
  }
}

历史站点配置上有一个重复的“听”指令,我删除了它......但由于某种原因,我仍然收到错误:'

sudo nginx -t nginx:[emerg] 在 /etc/nginx/sites-enabled/hist:6 中为 [::]:80 重复侦听选项 nginx:配置文件 /etc/nginx/nginx.conf 测试失败

4

2 回答 2

1

请试试

proxy_pass http://backend;

如果您的上游定义如下,请确保您可以访问http://127.0.0.1:3000/chsk

upstream backend {
    server 127.0.0.1:3000;
}

或者,如果我们只有一台后端服务器,我们可以使用 proxy_pass 而不定义上游后端。例如

proxy_pass http://127.0.0.1:3000;
于 2015-08-18T10:40:47.787 回答
0

我今天学到了一个新的教训:Nginx Web 服务器上的两个站点不能有相同的监听端口!我将新站点移至新端口并更新了所有链接...问题已解决!

于 2015-08-19T00:28:04.633 回答