使用Nginx作为反向代理(https)的node.js(express)上的Alexa Skill Server [英] Alexa Skill Server on node.js (express) using nginx as reverse proxy (https)

查看:122
本文介绍了使用Nginx作为反向代理(https)的node.js(express)上的Alexa Skill Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的Debian 8.5 64bit上运行一个nginx,用作我的节点应用程序的反向代理.每个请求都会先经过我的反向代理,然后再路由到特殊应用.因此,我正在使用此配置:

i am running a nginx on my Debian 8.5 64bit which is used as reverse proxy for my node applications. Each request walks through my reverse proxy before getting routed to the special apps. Therefor i am using this config:

upstream socket_nodes {
  server 127.0.0.1:3000;
  server myUrl.com:3000;
  server MY.ROOTSERVER.IP.ADDRESS:3000;
}
server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name myUrl.com;
  return 301 https://$server_name$request_uri;
}

server {
  # SSL configuration
  #
  listen 443 ssl default_server;
  listen [::]:443 ssl default_server;
  include snippets/ssl-my-website.com.conf;
  include snippets/ssl-params.conf; 

  # Self signed certs generated by the ssl-cert package
  # Don't use them in a production server!
  #
  # include snippets/snakeoil.conf;

  # Add index.php to the list if you are using PHP
  index index.html index.htm index.nginx-debian.html;

  server_name www.myWebsite.com;
  root /root/webserver/app/;
    location ~ /.well-known {
            allow all;
    }
  location / {
     proxy_pass http://localhost:8080;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection 'upgrade';
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;
  }
    location /alexa-api/ {
     proxy_pass http://localhost:3000;
  }
  location /at_backend/ {
    proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://socket_nodes;
  }


  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  #location ~ \.php$ {
  # include snippets/fastcgi-php.conf;
  #
  # # With php5-cgi alone:
  # fastcgi_pass 127.0.0.1:9000;
  # # With php5-fpm:
  # fastcgi_pass unix:/var/run/php5-fpm.sock;
  #}

  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  # deny all;
  #}
}

不幸的是,这不起作用.我可以通过https( https://www.myWebsite.com )访问我的网站,并且可以正常运行.

Sadly this is not working. I can reach my website via https (https://www.myWebsite.com) and it works fine.

所以我将Amazon Developer Console中我的alexa技能的终点更改为:https://www.myWebsite.com/alexa-api(有和没有尾随/),但是它不起作用.当我在本地使用技能服务器并通过ngrok使其可用时,技能服务器本身即可工作.我在这里做错什么了?

So i changed the endpoint of my alexa skill in the Amazon Developer Console to: https://www.myWebsite.com/alexa-api (with and without trailing /) but it is not working. The skill server itself worked when i used it locally and made it available via ngrok. What am i doing wrong here?

在同一应用程序中还运行着一个socket.io服务器,该服务器可以从Internet访问(服务器登录新客户端已连接")-但我无法在它们之间发出任何事件. socket.io连接的HTTP Status Code(正确)是101 Switching Protocols.

There is also a socket.io server running in the same app which can be accessed from the internet (the server loggs "new client connected") - but i can not emit any events between them. The HTTP Status Code of the socket.io connection is (correctly) 101 Switching Protocols.

问候

推荐答案

使用HTTPS时,您还应该通过https方案

When you have a HTTPS you should also pass https scheme

proxy_pass https://socket_nodes;

这篇关于使用Nginx作为反向代理(https)的node.js(express)上的Alexa Skill Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆