Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

502 bad gateway #38

Closed
Brantlab opened this issue Jun 27, 2019 · 13 comments
Closed

502 bad gateway #38

Brantlab opened this issue Jun 27, 2019 · 13 comments

Comments

@Brantlab
Copy link

Deployed on ubuntu 18.04 and ran the setup sh but I get 502 bad gateway.

@Brantlab
Copy link
Author

sudo tail -30 /var/log/nginx/error.log

https://pastebin.com/d576haUZ

@Brantlab Brantlab reopened this Jun 27, 2019
@Brantlab
Copy link
Author

Didn't mean to close it.

@bitbound
Copy link
Collaborator

It looks like the Nginx configuration was set up with "remotely.example.com" as the host name. The host name needs to be an actual URL/IP that points to the machine/VM, or the connection will be rejected.

This is true for any Nginx server that wants to host multiple sites on one machine (not just a Remotely thing). Since I don't know ahead of time if you intend to host multiple sites, it's configured to only accept traffic for a specific host name. You can manually change the Nginx configuration to "catch all" if you'd prefer that.

@Brantlab
Copy link
Author

I whitelisted the private info.... Sorry I should of specified.

@Brantlab
Copy link
Author

Let me give you a better description.

I deployed a brand new install of Ubuntu of 18.04
Downloaded and unzipped the repo
Ran the Remotely_Server_Install.sh with sudo.
Followed the prompts
script finished and I went to domain remote.example.com < protecting my domain by not posting it....
502 Gateway error

@bitbound bitbound reopened this Jun 27, 2019
@bitbound
Copy link
Collaborator

Sorry for the misunderstanding. I get a lot of emails where people literally enter "example.com," so I just assumed. My bad.

I just tested deploying on a fresh VM, and all went smoothly. Could you try checking the output of the following?

nginx -t
systemctl status remotely
wget --spider localhost:5000 (unless port was changed)

What are the results of those?

@Brantlab
Copy link
Author

remotely@remotely:~$ sudo nginx -t
[sudo] password for remotely:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

remotely@remotely:~$ systemctl status remotely
● remotely.service - Remotely Server
Loaded: error (Reason: Exec format error)
Active: inactive (dead)

Jun 27 06:56:12 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:13 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:14 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:14 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:14 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:54 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:54 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:56 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:57 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
Jun 27 06:56:57 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path
lines 1-14/14 (END)
● remotely.service - Remotely Server
Loaded: error (Reason: Exec format error)
Active: inactive (dead)

Jun 27 06:56:12 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:13 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:14 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:14 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:14 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:54 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:54 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:56 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:57 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.
Jun 27 06:56:57 remotely systemd[1]: /etc/systemd/system/remotely.service:5: Working directory path '' is not absolute.

remotely@remotely:~$ wget --spider localhost:5000
Spider mode enabled. Check if remote file exists.
--2019-06-27 19:59:53-- http://localhost:5000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5000... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:5000... failed: Connection refused.

remotely@remotely:~$ wget --spider localhost:80
Spider mode enabled. Check if remote file exists.
--2019-06-27 20:00:02-- http://localhost/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 612 [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

remotely@remotely:~$ wget --spider localhost:443
Spider mode enabled. Check if remote file exists.
--2019-06-27 20:00:09-- http://localhost:443/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:443... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:443... connected.
HTTP request sent, awaiting response... 400 Bad Request
Remote file does not exist -- broken link!!!

@bitbound
Copy link
Collaborator

It looks like the service isn't starting because the WorkingDirectory is blank (which means ExecStart is likely incorrect as well).

The first prompt of the install script asks for the root path where the app is installed (i.e. where the Remotely_Server.dll is located). I might want to make the prompt a little more clear. It sets it in the service file like so:

[Service]
WorkingDirectory=$appRoot
ExecStart=/usr/bin/dotnet $appRoot/Remotely_Server.dll

Check your service config (/etc/systemd/system/remotely.service) and make sure those values have the absolute path in them. Let me know if that was it. :)

@bitbound
Copy link
Collaborator

Actually, looking at this again, that variable is used for several other commands. You might just want to run the script again if that variable was indeed blank.

@Brantlab
Copy link
Author

Brantlab commented Jun 28, 2019

Here is a video of what I am doing during the re-run of the script. This link expires in 1 day. We aren't using this in production or anything. Its for my homelab I just work from home so it was easier to send it this way.

@bitbound
Copy link
Collaborator

When it's asking for the app path, it looks like you're entering an empty string. It's expecting the absolute path to where you want to install the app/website. See here: https://lucency.co/ImageShare/?view=lvwjryji1p2

That path is stored in a variable and used throughout the rest of the script.

@Brantlab
Copy link
Author

10/10 User error. Works now! Thanks! I thought when it mentioned "typically /var..." that was the default and if you wanted something different please enter it now. Bad on me for making the assumption.

@bitbound
Copy link
Collaborator

No problem!

Now that you mention it, I think someone else gave me similar feedback once.

I added that as the "default" location, so it behaves you described above. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants