SWAG nginx: [emerg] "location" directive is not allowed here in /config/nginx/site-confs/node-red.subfolder.conf:6

SWAG has been working great for 10 of my containers, i am now trying to get node-red to work with it

I get the following error when trying to setup node-red with swag

nginx: [emerg] “location” directive is not allowed here in /config/nginx/site-confs/node-red.subfolder.conf:6

Line 6 in my nodered.subfolder.conf file starts with

    location /nodered {

This part of my docker-compose.yml file which works fine

node-red:
image: nodered/node-red
container_name: node-red
environment:
  - TZ=America/New_York
volumes:
  - /etc/localtime:/etc/localtime:ro
  - /media/username/nfsset/containers/node-red/data:/data
ports:
 - 1880:1880 
restart: unless-stopped

This is my nodered.subfolder.conf file

  # REMOVE THIS LINE BEFORE SUBMITTING: The structure of the file (all of the existing lines) should be kept as close as possible to this template.
# REMOVE THIS LINE BEFORE SUBMITTING: Look through this file for <tags> and replace them. Review other sample files to see how things are done.
# REMOVE THIS LINE BEFORE SUBMITTING: The comment lines at the top of the file (below this line) should explain any prerequisites for using the proxy such as DNS or app settings.
# first go into <container_name> settings, under "General" set the URL Base to /<container_name>/ and restart the <container_name> container

location /nodered {
return 301 $scheme://$host/nodered/;
}

location ^~ /nodered/ {
# enable the next two lines for http auth
#auth_basic "Restricted";
#auth_basic_user_file /config/nginx/.htpasswd;

# enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
#auth_request /auth;
#error_page 401 =200 /ldaplogin;

# enable for Authelia, also enable authelia-server.conf in the default site config
#include /config/nginx/authelia-location.conf;

include /config/nginx/proxy.conf;
resolver 127.0.0.11 valid=30s;
set $upstream_app node-red;
set $upstream_port 1880;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;

# REMOVE THIS LINE BEFORE SUBMITTING: Additional proxy settings such as headers go below this line, leave the blank line above.
}

it’s a little hard to read your post… so i didn’t, but if you get this error, it means you did something wrong. just based on the subject, i can say you put node-red.subfolder.conf in the wrong place, it likely also contains an inappropriate location directive on line 6.

I suggest using our templates, in the same location you find them, and modifying that.

Thank you for your response
i just fixed the formatting sorry about that
I got this error by finding the _template.subfolder.conf.sample and renaming it and just filling in the blanks
container_name changed to node-red
port_number change to 1880
http or https changed to http

but why did you move it here
/config/nginx/site-confs/

proxy configs dont go in site-confs, they go in proxy-confs

this is what is causing your issue, if i had to guess

1 Like

you have blown my mind,

I have 10 containers running as subdomain and i dont know why but i moved them all into /swag/config/nginx/site-confs and they work fine

This is the first subfolder i am working on and i get the error,

I moved them all back to proxy-confs and everything works great now…

I am able to get into node red by

homeassistant.mydomain.com/nodered but it doesnt fullly work

The home assistant webpage loads but the nodered area stays blank… i wonder what else i have to do, maybe fill in the blanks at the bottom?

# REMOVE THIS LINE BEFORE SUBMITTING: Some proxies require one or more additional location blocks for things like API or RPC endpoints.
# REMOVE THIS LINE BEFORE SUBMITTING: If the proxy you are making a sample for does not require an additional location block please remove the commented out section below.
# location ^~ /<container_name>/api {
#     include /config/nginx/proxy.conf;
#     resolver 127.0.0.11 valid=30s;
#     set $upstream_app <container_name>;
#     set $upstream_port <port_number>;
#     set $upstream_proto <http or https>;
#     proxy_pass $upstream_proto://$upstream_app:$upstream_port;
# 
#     # REMOVE THIS LINE BEFORE SUBMITTING: Additional proxy settings such as headers go below this line, leave the blank line above.
# }

you probably need some kinda websocket stuff… i would ask the node-red people… there’s also a chance that subfolder just isn’t supported by the app itself (it’s why we prefer subdomain, it has no dependence on the app.)

you could take a look at… actually maybe the homeasistant one has websockets… i know some of them do, you can use that as an example

1 Like

thank you for pointing me in the right direction

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.