#Nextjs deployment with plesk

33 messages · Page 1 of 1 (latest)

storm saddle
#

I'm having a hard time trying to deploy my first freelance project to plesk, can someone with experience help me with that.

queen violet
#

Hi

lethal bluff
storm saddle
#

hi thx for reaching out

#

where should I put my project and install it ?
in var/www/vhosts/my-domain-name/httpdocs
or should put it outside the httpdocs and install it manually with nginx and pm2

#

@lethal bluff

lethal bluff
#

Sorry for late reply.

#

Since you're deploying a custom application (not a standard PHP app), the best practice is not to place it inside the httpdocs directory.

storm saddle
#

ok i will tell you the steps i did :

  • install nginx
  • configure nginx file :
    server {
    listen 8080;
    server_name 51.38.239.237;
    location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    }
    }
    i used 8080 so it doesnot conflict with apache2
  • deleted the default nginx config
  • created a symbolic link with this command :
    sudo ln -s /etc/nginx/sites-available/nextjs.conf /etc/nginx/sites-enabled/
    -restart nginx and checked the status and it is active
  • cloned my project inside var/www/nextjs so the directory is var/www/nextjs/(myreponame)
  • cd into my repo then npm install then npm build and npm start
    all works fine till this
#

after this i install pm2 and start the app with this command pm2 start npm --name "nextjs" -- start

#

then i go for my ip address but i cannot find my project

#

@lethal bluff

lethal bluff
#

Sorry again.
It was sleep.
It was midnight in our country

lethal bluff
storm saddle
#

Actually it worked on 8080 port

#

But i want it to work on the domain instead i will try to change the config nginx file and see if it is going to work

lethal bluff
#

Yes, to make it work on the domain, you can update the nginx config to use your domain name in server_name and set it to listen on port 80 (or 443 for HTTPS).

storm saddle
#

The problem is i cannot make it work on 80 because apache2 is using that so will it be a problem if i used 8080? Cuz for now the url is myip:8080 so if I use the domain will it be only the domain as the url or it will be the domain:8080?

lethal bluff
storm saddle
#

I can not disable apache2 because plesk runs internally with it

#

I broke plesk when i did that yesterday

#

So i guess option 2

lethal bluff
#

I understand.

#

you are right!

#

You (or your server admin) can set up Apache in Plesk to proxy the domain to nginx on port 8080 — that way, users can just access yourdomain.com without needing :8080.

storm saddle
#

i want to make it work on mydomain:8080 for now atleast just to test it and it doesnot so when i hit matech-x.com:8080 in my browser it doesnot work is there something wrong on my nginx conf? and the app is running fine on my (ipaddress:8080)

#

@lethal bluff

lethal bluff
#

Hi, sorry for late reply.

If yourdomain.com:8080 isn't working but your-ip:8080 is, the issue is likely DNS or firewall-related.
The nginx config looks fine.

Please make sure:

  1. The domain matech-x.com is pointing to your server's IP (check DNS A records).
  2. Port 8080 is open in your server's firewall and hosting provider's panel.
  3. Your hosting provider isn’t blocking public access to custom ports (some do for security).

Once DNS resolves and the port is open, matech-x.com:8080 should work just like the IP.

storm saddle
#

sorry i meant it works on myip:8080 not my domain

storm saddle
#

iam confused now because when i run ping matech-x.com it return back my ip address which is good but when i run ping matech-x.com 8.8.8.8(google dns) in plesk it doesnot return my ip but it returns my ip on my local machine with the google dns

#

so iamnot sure if the domain is connected to the ip

lethal bluff
#

It sounds like your domain DNS is set up correctly externally (since ping returns your IP on your local machine), but inside your Plesk server, it might be using a different DNS resolver or caching old records.
Try running:
dig matech-x.com @8.8.8.8
or
nslookup matech-x.com 8.8.8.8

on the server to confirm the public DNS resolution.
If it still doesn't show your IP, the domain isn’t fully propagated or your server is caching old DNS.
Give it some time or flush the DNS cache.

storm saddle
#

are u using ai to respond to me ?