C
C
Chvalov2017-09-01 03:01:21
Nginx
Chvalov, 2017-09-01 03:01:21

I can't reach the web page, it redirects to the site, what's the problem with vhost?

Debian 8 server, ip 192.168.1.200
There are two configs in the nginx configs, one for the site www.site.com.ua, the second for accessing pma in this form 192.168.1.200/pma
but when you go to such a url, a redirect to www. site.com
cat /etc/nginx/conf.d/site.com.conf

server {
    listen 80;
    server_name www.site.com.ua site.com.ua;
    return 301 https://site.com.ua$request_uri;
    access_log off;
    error_log off;
}

server {
    listen 443 ssl http2;
    access_log off;
    error_log off;
    server_name www.site.com.ua;
    return 301 https://site.com.ua$request_uri;
    ssl        on;
    ssl_certificate         /var/ssl/site.com.ua/origin.pem;
    ssl_certificate_key     /var/ssl/site.com.ua/private.key;
}

server {
    listen 443 ssl http2;
    ssl        on;
    ssl_certificate         /var/ssl/site.com.ua/origin.pem;
    ssl_certificate_key     /var/ssl/site.com.ua/private.key;
    add_header Strict-Transport-Security "max-age=15768000" always;
    ssl_protocols TLSv1.2;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;

    root /var/www/html/site.com.ua;
   index index.php;
    server_name site.com.ua;

    error_log      /var/log/site.com.ua/site.error.log;
    access_log /var/log/site.com.ua/site.access.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    gzip on;
    gzip_http_version 1.1;
    gzip_disable "msie6";
    gzip_comp_level 9;
    gzip_types text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/ja$

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|rtf|js|css|ttf|woff|woff2)$ {
        expires 7d;
        etag on;
    }

    location /ws {
       proxy_pass http://node;
       proxy_http_version 1.1;
       proxy_set_header Upgrade websocket;
       proxy_set_header Connection upgrade;
    }
}

upstream node {
  server 127.0.0.1:8080 fail_timeout=20s;
}

Config for pma (which should be accessible via ip.ip.ip.ip/path )
cat /etc/nginx/conf.d/others_script.conf
server {
    listen 80;

    root /var/www/html/others;
    index index.php index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

        access_log /var/log/other_site/access.log;
        error_log /var/log/other_site/error.log;

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

In the /var/www/html/others directory there are
index.php, info.php pma/ (directory)
But no matter how I pound on ip, a redirect occurs
Just in case, the /etc/hosts file was not touched

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Valle, 2017-09-01
@v1pby

server_name localhost;
Try to pull the url from the localhost where nginx is located:
If yes, then you need to either make this vhost default or remove the server_name altogether.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question