Failed to load resource: the server responded with a status of 502 (Bad Gateway)

root@felipe-udeabase:~# sudo systemctl status metabase
● metabase.service - Metabase server
	 Loaded: loaded (/etc/systemd/system/metabase.service; enabled; vendor preset: enabled)
	 Active: active (running) since Tue 2022-06-07 21:40:58 UTC; 6min ago
   Main PID: 21095 (java)
	  Tasks: 62 (limit: 9406)
	 Memory: 801.1M
	 CGroup: /system.slice/metabase.service
			 └─21095 /usr/bin/java -jar /var/metabase.jar

Jun 07 21:41:12 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:12,225 INFO core.QuartzScheduler :: Scheduler MetabaseSchedule>
Jun 07 21:41:12 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:12,227 INFO metabase.task :: Task scheduler started
Jun 07 21:41:12 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:12,228 INFO metabase.core :: Metabase Initialization COMPLETE
Jun 07 21:41:12 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:12,265 INFO task.refresh-slack-channel-user-cache :: Slack is >
Jun 07 21:41:25 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:25,688 INFO middleware.misc :: Setting Metabase site URL to 19>
Jun 07 21:41:26 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:26,101 INFO i18n.impl :: Reading available locales from locale>
Jun 07 21:41:26 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:26,193 INFO util.fonts :: Reading available fonts from /fronte>
Jun 07 21:41:27 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:27,084 WARN protocol.ResponseProcessCookies :: Invalid cookie >
Jun 07 21:41:27 felipe-udeabase.com metabase[21095]: 2022-06-07 21:41:27,837 DEBUG middleware.log :: GET /api/session/properties 200>
Jun 07 21:45:47 felipe-udeabase.com metabase[21095]: 2022-06-07 21:45:47,658 DEBUG middleware.log :: GET /api/session/properties 200>

and

nano /etc/systemd/system/metabase.service

##
[Unit]
	Description=Metabase server
	After=syslog.target
	After=network.target[Service]
	User=username
	Type=simple

[Service]
	ExecStart=/usr/bin/java -jar /var/metabase.jar
	#ExecStart=/usr/bin/java -DMB_JETTY_PORT=3100 -jar /apps/java/metabase.jar
	EnvironmentFile=/var/metabase/metabase-env
	Restart=always
	StandardOutput=syslog
	StandardError=syslog
	SyslogIdentifier=metabase

[Install]
	WantedBy=multi-user.target
##

how solve this?

root@felipe-udeabase:~# sudo nginx -t
nginx: [warn] conflicting server name "felipe-udeabase.com" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Hi @mgtrfelipeurrego, this seems to be an issue with Nginx, maybe a bad configuration. So please post your Nginx conf. Or completely delete nginx and run only Metabase (but know the limitations of doing this)

cd /etc/nginx/sites-available

and edit with this

nano ngnix.conf

SSL
#add these lines
server {
listen felipe-udeabase.com:443;
server_name felipe-udeabase.com;
return 301 http://felipe-udeabase.com:3000; }
#(for nano ctrl-o then ctrl-m and then ctrl-x it will save and exit the file)

cd /etc/nginx/sites-enabled/
touch felipe-udeabase.com.conf
nano felipe-udeabase.com.conf

#add this line
server
{
 listen 443 ssl;
 server_name felipe-udeabase.com www.felipe-udeabase.com;
 location /
 {
 proxy_set_header Host $http_host;
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Forwarded-Server $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Graylog-Server-URL https://domain.com/api;
 proxy_pass http://felipe-udeabase.com:3000;
 # proxy_pass http://felipe-udeabase.com:3000;
 }
 #ssl on;
 ssl_certificate /root/.local/share/mkcert/felipe-udeabase.com+4.pem;
 ssl_certificate_key /root/.local/share/mkcert/felipe-udeabase.com+4-key.pem;
 ssl_session_timeout 5m;
 ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
 ssl_protocols TLSv1.2;
 ssl_prefer_server_ciphers on;
 access_log /var/log/nginx/felipe-udeabase.com.access.log;
 error_log /var/log/nginx/felipe-udeabase.com.error.log;
}

# http to https redirection
server {
	listen 80;
	server_name felipe-udeabase.com www.felipe-udeabase.com;
	add_header Strict-Transport-Security max-age=2592000;
	rewrite ^ https://$server_name$request_uri? permanent;
}
#

and this one

nano /etc/nginx/sites-available/metabase

##

server {
		listen 443;
		server_name felipe-udeabase.com;
		ssl_certificate /root/.local/share/mkcert/felipe-udeabase.com+4.pem;
		ssl_certificate_key /root/.local/share/mkcert/felipe-udeabase.com+4-key.pem;
		#ssl on;
		access_log /var/log/nginx/metabase.access.log;
		location / {
				proxy_pass
				#http://192.168.0.13:3000;
				http://localhost:3000;
				proxy_set_header host $host;
				proxy_http_version 1.1;
				proxy_set_header upgrade $http_upgrade;
				proxy_set_header connection "upgrade";
		}
}

##

next this

ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/metabase

nginx -t

nginx: [warn] conflicting server name "felipe-udeabase.com" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "felipe-udeabase.com" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Please use a simple Nginx config like

server {
    listen 80;
    listen [::]:80;
   
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_header Server;
    proxy_connect_timeout 3s; 
    proxy_read_timeout 10s;
    # server_name your.domain.com;
    # if ($scheme != "https") {
    #     return 301 https://$host$request_uri;
    # }
    # }

    location / {
        proxy_pass http://localhost:3000;
    }
}

Once you have nginx and metabase working together then start adding https/certs, etc. The config you sent above has a lot of conflicts (many servers have the same name)

still failing, pls view this video with all my enviroment

Hi @mgtrfelipeurrego, so you're running the Metabase instance locally in your network? (192.168.0.13) if that's the case, unless you override the DNS entry of "felipe-udeabase.com" either in your machine (if the DNS entry is cached) or in your router, then every time you try to go to that URL your router will end up going to any IP outside your network.

I need put domain with port 80 not 3000

Example.com:3000 is Solving buy example.com not solving

Any suggestions?

@mgtrfelipeurrego
You tell Metabase to run on port 3100 (DMB_JETTY_PORT=3100), but your Nginx config is referencing it at port 3000 (proxy_pass ...)

  1. First setup Metabase so it's only accessible on localhost, meaning you should not be able to access it via example.com:3000
  2. Then setup your Nginx config, so there are no conflict warnings, meaning you should only have a single server-section per server_name+listen.
  3. Then make a proxy_pass http://localhost:3000;
    As described in the documentation:
    https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-debian.html#ensure-nginx-is-setup-to-proxy-requests-to-metabase
    Or a slightly more complete configuration as shown here: MySQL SSL connection
  4. After Metabase is available on https://example.com, then make sure to adjust Site URL in Metabase > Admin > Settings > General, so it matches how Metabase is being accessed.

My issues is about SSL
Can u share correct files for do that
I only resolve example.com:port
Because https in port 80 is not working
I don't know my error
About 3000 and 3001 is only testing

@mgtrfelipeurrego Post your updated configurations.

sites-avaible:

sites-enabled:

i need
example.com without ssl is fine for now, because is a local deployment develop instance

@mgtrfelipeurrego Just add this to the server-section of whichever site is running:

    location / {
        proxy_pass http://localhost:3000;
    }

If you cannot get it to work, then I'll recommend that you try getting help in a Nginx forum, since it has nothing to do with Metabase, but just incorrect configuration of Nginx.
Or use Apache if you're more familiar with that. Or any other reverse-proxy like Caddy etc...