Plesk Obsidian - docker domain proxy not working - node.js

I have a problem with my Plesk server. I am using Plesk Obsidian 18.0.28 on Ubuntu Server.
I have a custom nodejs api inside a container up and running.
If I type domain.tld:3000, I get "ok" as response as expected and my api is accessible.
I added a proxy rule to proxy api.domain.tld to the running docker container, but when I visit the domain, I get an 403 Error as response.
Do I need to make some settings changes anywhere in plesk to get this to work? This does not work
with other containers either.
I appreciate every helpful hint I can get.

I found the error:
nginx was not installed & plesk installer was crashed
If I clicked on tools & settings => plesk => updates & upgrades the page was loading forever. Normally you can install nginx there.
Solution:
Log into your terminal (e.g. via putty)
Install nginx reverse proxy with: plesk installer --select-release-current --install-component nginx
If you get an error message, that an installer is already running, you can force that plesk installer to stop with: plesk installer stop
After you installed nginx, you just need to start it once manually.
For more information, see here: https://support.plesk.com/hc/en-us/articles/213944825-How-to-install-and-enable-nginx-reverse-proxy-on-a-Plesk-for-Linux-server
and here: https://support.plesk.com/hc/en-us/articles/213917525-Unable-to-open-the-Updates-and-Upgrades-page-or-start-Plesk-Installer-in-CLI-Update-operation-was-locked-by-another-update-process
But I'm still confused why I got no error message at all when trying to use proxy rules without nginx.

Related

Is there any way to manage node.js server from web interface?

I am in need to manage my node server without entering into server console. I have tried using forever, nodemon and pm2 npms. Whenever, I need to start or stop the node application, I need to connect the server via terminal. I want to avoid that and willing to see the possibility if that can be managed through any web interface or any browser plugin/extension.
Already tried forever, nodemon and pm2
You can use npm pm2-gui install it by this command npm i pm2-gui
See the docs and guides from here https://www.npmjs.com/package/pm2-gui
I started looking for some GUI and Web interface of PM2. Tried several npms but "mc-pm2-web" worked really good for me.
I am using Node via NVM and my node version was v10.15.3. Installed this https://www.npmjs.com/package/mc-pm2-web and it was straight forward what I was actually looking for.
Here's are the step if anybody wants to install and configure "mc-pm2-web" in AWS EC2.
I am using Amazon Linux
I am using NVM and running v10.15.3
Already had NGINX & PHP-FPM running on server using port 9000
pm2 already installed
Visit this link:
https://www.npmjs.com/package/mc-pm2-web
npm install -g pm2-web
pm2-web
If you encountered any error then you may check your config.json file. In my case the config file path was:
/home/ec2-user/.nvm/versions/node/v10.15.3/bin/pm2-web/config.json
I made following changes in config file to make it working:
Port from 9000 to 9010 because 9000 was being used by PHP-FPM
Changed the host name from "localhost" to "my-domain" which was already hosted in NGINX
Enabled authentication and set the Username and Password for making it secure
Allowed 9010 port from AWS EC2 firewall / security group of that instance
Added pm2-web in pm2 by executing "pm2 start pm2-web" command

Docker behind a proxy requires restart on boot

I apologise if I am posting this in the wrong section, I need some help and unsure where to turn to.
I am trying to run docker behind a proxy on a linux/ubuntu server machine. I have configured every proxy on the box (FTP/HTTPS/HTTP), I have also configured the Docker proxies mentioned here: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy and https://stackoverflow.com/a/28093517/4261713
However, I have the docker service set to auto-start on machine boot, unless I log onto the machine and run sudo service docker restart those settings are ignored, and docker fails to use a proxy. This is all fine, we have a work around for local access, but I need to use this machine remotely using auto-builds/deployments etc. Therefore, the builds break without running that command.
Unfortunately I cannot get any help from Docker support, I have waited around 3 weeks for them to reply with no luck. This problem is more than likely me not understanding linux services/daemons. Can someone help me out?
To confirm what I have already tried:
I have created the http-proxy.conf in /etc/systemd/system/docker.service.d and created the Environment variable there for the proxy.
I have tried to modify the docker service init.d file by adding to the "DOCKER_OPTS" variable at the top using -e "HTTP_PROXY=http://addressofproxy:portofproxy" -e "HTTPS_PROXY=http://addressofproxy:portofproxy" However, this also has made no difference and I still need to restart the service after a reboot!
EDIT: I have also set/configured the client config in ~/.docker/config.json to have the proxies in. (as mentioned in the answers below by Kerat)
Any assistance is much appreciated, I am totally stuck with why it wont read the options in on startup.
This turned out to be a double instance installation. Confusingly ubuntu server comes with docker installed under package manager - snap, so installing under apt-get led to double installation.
I think this is a poor way to manage Ubuntu server, I would expect a plain, vanilla OS with nothing installed.. Hopefully this helps someone else in the future!
have you tried to configure the proxy in ~/.docker/config.json with :
{
"proxies":
{
"default":
{
"httpProxy": "http://127.0.0.1:3001",
"httpsProxy": "http://127.0.0.1:3001",
"noProxy": "*.test.example.com,.example2.com"
}
}
}
as mentionned at https://docs.docker.com/network/proxy/#configure-the-docker-client ?

Shows only default page in ubuntu using valet-linux

I installed valet-linux in kubuntu 18.04 and followed the documentation. I also changed the path to make valet command works. I also added the directory of my projects which is located in another partition using valet park and change its port to 8888 so it won't have conflict with apache which listens to port 80.
But when I run my-laravel-project.test it shows the Apache2 Ubuntu Default Page not my laravel project page which when I tested it using php artisan serve, it is working. Thanks!
I experienced the same.
Can you check if valet is running correctly?
valet status
In my case it looked like this:
Php7.2-fpm is running...
Nginx is stopped...
So I fixed it by stopping, apache since it was obviously interfering with valet:
sudo service apache2 stop
I checked the status again
valet status
and now it looked fine:
Php7.2-fpm is running...
Nginx is running...
Now Valet worked for me on Ubuntu.
add DirectoryIndex index.php to your apache config

Connecting app to AWS EC2 instance

I'm pretty new to DevOps and I'm trying to set up my Node.js app on a AWS server instance. Steps I've taken:
Set up Elastic IP
Launched EC2 instance with Ubuntu server
Connected IP to instance
Allowed incoming connections on port 3000
SSH'd into the server with a .pem file
Now I'm at the point where I need to get my files uploaded to the server. I've used FileZilla (and like it) in the past to upload files but the initial part was already set up. When I set up the site on FileZilla there is no /var/www folder on the remote site.
Don't know how to connect these dots.
Also not sure what I need to run once I successfully upload the files. I imagine npm install when I'm ssh'd into the server? Most of the tutorials out there only go through the basic instance setup.
Thanks!
You don't need to have /var/www. Also, it's better that you use a version control and a remote repository like Github and then SSH to your EC2 and then clone your repository there.
Then cd into your repo and run npm install and then start your app.
And check.
Once you connect to the EC2 instance then clone your code in there. It not mandatory to be in /var/www/html but, it's best practice to keep it there. Once you clone npm install into your project home directory so all the required packages get installed. Then for running your node application in production you have to run it on service as pm2, supervisor, forever, passenger, etc. You can use any of these services and configured appropriately to run your application on desired port. As with pm2, you can follow this guide, install pm2 Then you can run with the following command w.r.t. your environment, like I want to run my application on port 5555 for production
$ PORT=5555 pm2 start app.js --name API --env production -f
Check the status using pm2 list Now, your application is running on http://server-ip:5555/ But, you won't be typing port number every-time. So, you need to configure the web server in front of your application like apache or nginx which will forward all request to your application running port. You could find the best guide to their home page. Then your application is available at http://server-ip/ You can follow this for single configuration of multiple node apps
Hope this helps.

First time setting up Ghost blog on Amazon Ec2 various noob questions

Ok so here's some quick info about my setup:
-Amazon Ec2 instance with an elastic IP associated to it
- Latest versions of node and Ghost
- Using Windows 8 with Putty
- Domain from Namecheap
So I installed ghost and node on my Amazon EC2 instance using this guide: http://www.bybigs.com/setup-ghost-on-amazon-web-services/
Everything went well(I think). Just at the part where I have to change the IP addresses I'm not sure I did everything correctly. Do I have to change every IP address I see? I found a lot of 127.0.0.1 adresses that I went ahead and changed to my private IP from AWS. I also changed the link to my domain.
The problem I've run into now is the last step: So, type npm install forever -g and once that's done you can start the server by typing NODE_ENV=production forever start index.js, and you can close the SSH window.
I seem to get quite a few error messages when I type in npm install forever -g so I don't even move on. But when I type in npm start everything seems to be ok.
Now my other problem is with my domain. I bought it on namecheap and read online I need to change the A record to point to my elastic IP. I've done that for the A www and # record. Is there anything else I need to do?
When I go on my domain it shows up as this page cannot be displayed. So something must have gone wrong along the way. Can anybody help a noob out?
Can you post the output when you run npm install forever -g?
You only have to change the IP address in the production section.
Is there a particular reason you want to use Forever? If the only reason is because of the tutorial you linked to checkout out my post on running Ghost with pm2.
Lastly, if you do not want to do the setup to get Ghost running on an EC2 instance you can use our AWS AMI. The AMI has everything pre installed and running so you just have to launch it.

Resources