title: Nginx settings for webservics with SSL (https)
body: <p>Nginx newbie here! I have the following dummy code:</p>
  
  <pre><code>&lt;button onclick="myFunction()"&gt;Click me&lt;/button&gt;
  &lt;p id="demo_id"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  
  function myFunction() 
  {
      var loc = window.location;
      var wsStart = 'ws://';
      if (loc.protocol == 'https:') 
      {
          wsStart = 'wss://'
      }      
  
      var port =":8080" &lt;!-- 
      var endpoint = wsStart + loc.host + port+'/personal/my_random_number/';
  
  socket = new WebSocket(endpoint);
  
  socket.onmessage = function(e) 
  {
      document.getElementById("demo_id").innerHTML = e.data;
  }
  
  socket.onopen = function() 
  {
      socket.send("hello world #");
  } 
  
  &lt;/script&gt;
  </code></pre>
  
  <p>and nginx settings like this (ssl commented out):</p>
  
  <pre><code>server {
  listen 80;
  #listen 443 ssl;
  server_name 157.200.0.100;
  
   #ssl_certificate /etc/letsencrypt/live/mydomain.com-0002/fullchain.pem;
   #ssl_certificate_key /etc/letsencrypt/live/mydomain.com-0002/privkey.pem;
  
  
  # serve static files
  location /static/ {
  alias /www/static_3/;
  }
  
  # serve media files
  location /media/ {
  alias /www/media_3/;
  }
  
  location / {
  proxy_pass http://$server_name:8080;
  proxy_set_header X-Forwarded-Host $server_name;
  }
  }
  
  #server {
  #        listen 80;
  #        server_name 157.200.0.100;
  #        return 301 https://$host$request_uri;
  #}
  </code></pre>
  
  <p>while the web service works perfectly on http (non secure) I couldn't figure how to allow wss to work with ssl (I commented out the SSL settings, when I use the SSL setting, the site works ok but not the WSS). </p>
  
  <p><strong>Question:</strong> how to 'upgrade' my nginx settings where the WS can work with SSL?</p>