Skip to content

Guide: running webviewer behind Nginx with basic auth #170

@fmoessbauer

Description

@fmoessbauer

Hi,

I managed to run the webviewer behind a nginx reverse proxy with basic auth to expose it via the internet.
I'm wondering if this snippet could be included somewhere in the documentation:

server {
  # [...]
  auth_basic           "Login required";
  auth_basic_user_file /etc/nginx/.meshcore-bot.htpasswd;

  location / {
    # local webviewer instance
    proxy_pass      http://127.0.0.1:8080;
    proxy_buffering off;
    include /etc/nginx/proxy_params;
  }
  # websocket path
  location /socket.io/ {
      if ($http_connection !~* "upgrade") {
          return 403;
      }
      if ($http_upgrade !~* "websocket") {
          return 403;
      }
      proxy_pass http://127.0.0.1:8080;
      include /etc/nginx/proxy_params;

      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_read_timeout 86400;
  }
}

proxy_params

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

I'm happy to send a PR. Just tell me where to add it, or feel free to add by yourself.

Cheers! DL1FMP

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions