Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


nginx name based virtual hosts issue
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

nginx name based virtual hosts issue

GuyPGuyP Member

2 domains, 2 configs, 1 IP. Requests for domain2 end up loading/redirecting to domain1. Why?

/etc/nginx/sites-available/domain1.com:

https://clbin.com/xgr6i

/etc/nginx/sites-available/domain2.com

https://clbin.com/pOazk

There are links to both configs for domain1.com and domain2.com in /etc/nginx/sites-enabled/

Comments

  • joerijoeri Member, Host Rep, LIR
    edited March 2018

    I think you miss the listen (with ip) on the non SSL part

    listen XXX.XXX.XXX.XXX:80;

  • GuyPGuyP Member

    @joeri said:
    I think you miss the listen (with ip) on the non SSL part

    I tried that, same issue. Thank you for taking a look.

  • WebProjectWebProject Host Rep, Veteran
    edited March 2018

    and missing:

    server {

    listen listen 443 http2 ssl;

    server_name domain1.com www.domain1.com;

    why you do redirect to first domain?

        return 301 https://domain1.com$request_uri;
    
  • lemonlemon Member
    edited March 2018

    Do you have some plugin like ssl anywhere (in your browser)? Because the 2nd site only listens on port 80 and then it will open the next vhost which listens on port 443, which is site1 in your case.

  • Had this issue yesterday, and while 90% of the time I remove the ip before the port[xx.x.x.x.:80] in my config file, I fixed it by actually adding the ip to the file.

  • GuyPGuyP Member
    edited March 2018

    WebProject said: why you do redirect to first domain?

    To enforce no www per the client's request.

    lemon said: Do you have some plugin like ssl anywhere

    Aahh that might be it. Will test again later tonight. I do have HTTPS Everywhere installed.

Sign In or Register to comment.