skip to Main Content

I’ve already seen some answers on here and none of the solutions seem to work.

I have domain.com with a wordpress install
and a script running on domain.com:6000

I want to be able to have script.domain.com show what’s on domain.com:6000

Now the other big issue is plesk. (It gets a lot of hate but the people using the website like the UI.) but here’s what I’ve done/tried

New folder and file in /var/www/vhosts/domain.com/conf

file : vhost_nginx.conf
and what’s currently in it

server {
    listen 80;
    server_name script.domain.com;

    location / {
        proxy_pass http://domain.com:6000;
    }   
}

Also having tried

location /script/ {
   proxy_pass http://domain.com:6000/;
}

to try and have domain.com/script show something different.

Any suggestions?

2

Answers


  1. Right now in PLesk 12.5 there is no way to override "location /" via plesk, because all custom conf files are added at the end of nginx’s server section after default "location /" derectives.

    You can create or change hosting type of your subscription to forwarding like in this answer https://serverfault.com/a/541055/154664
    But in this case port will be visible in URL.

    Another solution is to create your own custom virtual host in nginx in some separate config – it’s actually easiest way now.

    Another solution is to customize virtual hosting templates, but it’s too much side effects on Plesk upgrade.

    Login or Signup to reply.
  2. I put this in the Plesk UI under additional nginx directives and it worked for me. You can remove the if, if you are ok with http traffic. Also replace <*> accordingly. For instance:
    <your-domain> = script.domain.com, <your-host> = localhost <your-port> = 6000

    if ($scheme = http) {
       return 301 https://<your-domain>;
    }
    
    location ~ / {
       proxy_pass       http://<your-host>:<your-port>;
    
       proxy_redirect   off;
    
       proxy_set_header Host $host;
    
       proxy_set_header X-Real-IP $remote_addr;
    
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    
       proxy_set_header X-Forwarded-Host $server_name;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search