Problem about redirect in NGINX

Markos

Well-known member
In the past i have transferred my site from this domain to this domain. I'm not a technical user, so my collaborator does this work.

My issue is that redirect goes bad, only the visits from the homepage to the old domain to the homepage of the new domain go right...and now i have THOUSANDS of Crawl errors...

The 301 redirect doesn't go WELL so now i have many parts of the old site indexed on Google...

I need help to correct the redirect from the Old Site to the New Site...My technician installed for me Centmin, but now he disappear...and i'm now in sh*t. :D

If someone can give me help here or can see on my site (i can give to trusted persons access to FTP/Admin Panel)...thank you!
 
Hi, looks like missing/wrong redirect rules... I can give you a hand with this.

Please post the contents of etc/nginx/conf.d/default.conf located at your old server (the server associated with your old domain). What is your old domain? Your new domain seems to be fifaplaza.net. Your link to your old domain is resolving to your new domain probably due to the redirect in place.

Edit: I think I'm seeing what the problem is. You probably have your old domain not associated with a server anymore, just your new domain is associated with your server, right?
 
Last edited:
I found this in the yplaza.conf (for the old domain):
Code:
# redirect from non-www to www
# uncomment, save file and restart Nginx to enable
#server {
#            listen   80;
#            server_name yplaza.net;
#            return 301 $scheme://www.yplaza.net$request_uri;
#       }

server {
    listen    80;
      server_name yplaza.net *.yplaza.net;
      return 301 https://$host$request_uri$is_args$args;

}

server {
          #server_name yplaza.net www.yplaza.net;

        listen 443 ssl spdy;
        server_name yplaza.net www.yplaza.net;

        ssl_certificate      /usr/local/nginx/conf/ssl/yplazanet/ssl-unified.crt;
        ssl_certificate_key  /usr/local/nginx/conf/ssl/yplazanet/ssl.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_session_cache      shared:SSL:10m;
        ssl_session_timeout  10m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA;
        ssl_prefer_server_ciphers   on;
        add_header Alternate-Protocol  443:npn-spdy/3;
        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
        #add_header  X-Content-Type-Options "nosniff";
        #add_header X-Frame-Options DENY;
        # nginx 1.5.9+ or higher
        # http://nginx.org/en/docs/http/ngx_http_spdy_module.html#spdy_headers_comp
        # http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size
        # spdy_headers_comp 0;
        # ssl_buffer_size 4k;

        # enable ocsp stapling
        resolver 8.8.8.8;
        ssl_stapling on;
        ssl_stapling_verify on;
        ssl_trusted_certificate /usr/local/nginx/conf/ssl/yplazanet/ssl-trusted.crt;




# ngx_pagespeed & ngx_pagespeed handler
#include /usr/local/nginx/conf/pagespeed.conf;
#include /usr/local/nginx/conf/pagespeedhandler.conf;
#include /usr/local/nginx/conf/pagespeedstatslog.conf;

  # limit_conn limit_per_ip 16;
  # ssi  on;

  access_log /home/nginx/domains/yplaza.net/log/access.log combined buffer=32k;
  error_log /home/nginx/domains/yplaza.net/log/error.log;

  root /home/nginx/domains/yplaza.net/public/under_costruction;

  #location / {

# block common exploits, sql injections etc
#include /usr/local/nginx/conf/block.conf;

  # Enables directory listings when index file not found
  #autoindex  on;

  # Shows file listing times as local time
  #autoindex_localtime on;

  # Enable for vBulletin usage WITHOUT vbSEO installed
  #try_files        $uri $uri/ /index.php;

  #}

    location / {
        rewrite ^ http://fifaplaza.net;
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$uri&$args;
    }
        location /internal_data/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }

        location /library/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }
      
        # Pass PHP scripts to PHP-FPM
        location ~* \.php$ {
            fastcgi_index   index.php;
               fastcgi_pass    127.0.0.1:9000;
               #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
              include         fastcgi_params;
               fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
               fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
            fastcgi_param  HTTPS  on;
            fastcgi_param  HTTP_SCHEME https;
        }

  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
}

server {
        listen 443 ssl;
        server_name fifa.yplaza.net;
      

        location /forum {
            rewrite ^ http://fifaplaza.net$request_uri? permanent;
        }
      
      
      
      
          root /home/nginx/domains/yplaza.net/public;
      
  
        location / {
            rewrite ^ http://www.fifaplaza.net/forum/$request_uri? permanent;
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$uri&$args;
        }
        location /internal_data/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }

        location /library/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }
      
        # Pass PHP scripts to PHP-FPM
        location ~* \.php$ {
            fastcgi_index   index.php;
               fastcgi_pass    127.0.0.1:9000;
               #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
              include         fastcgi_params;
               fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
               fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
            fastcgi_param  HTTPS  on;
            fastcgi_param  HTTP_SCHEME https;
        }
}

server {
        listen 443 ssl;
        server_name forums.yplaza.net;
          root /home/nginx/domains/yplaza.net/public/under_costruction;
      
        location / {
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$uri&$args;
        }
        location /internal_data/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }

        location /library/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }
      
        # Pass PHP scripts to PHP-FPM
        location ~* \.php$ {
            fastcgi_index   index.php;
               fastcgi_pass    127.0.0.1:9000;
               #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
              include         fastcgi_params;
               fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
               fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
            fastcgi_param  HTTPS  on;
            fastcgi_param  HTTP_SCHEME https;
        }
}

server {
        listen 443 ssl;
        server_name cdn.yplaza.net;
          root /home/nginx/domains/yplaza.net/public;
      
        location / {
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php?$uri&$args;
        }
        location /internal_data/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }

        location /library/ {
        internal;
        allow 127.0.0.1;
        deny all;
        }
      
        # Pass PHP scripts to PHP-FPM
        location ~* \.php$ {
            fastcgi_index   index.php;
               fastcgi_pass    127.0.0.1:9000;
               #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
              include         fastcgi_params;
               fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
               fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
            fastcgi_param  HTTPS  on;
            fastcgi_param  HTTP_SCHEME https;
        }
}

The redirect from fifa.yplaza.net/forum home to fifaplaza.net/forum home it's good. My problem is with discussions and other things...because i've customized with route filters some url...
 
Hi,

Within the following block:

Code:
server {
  listen  80;
  server_name yplaza.net *.yplaza.net;
  return 301 https://$host$request_uri$is_args$args;
}

Replace:

Code:
return 301 https://$host$request_uri$is_args$args;

With:

Code:
rewrite ^ https://fifaplaza.net$request_uri permanent;

Save, restart nginx and see if it works.
 
Last edited:
Thank you Super120, i restarted the server now for some things, i'm wait to see if the issue is resolved.
 
LOL restarted the server but is online and the staff said to me that they doesn't see any error, fantastic ahah. Trying to figure what the problem is...yawn.
 
Why did you rebooted the server? It's generally not necessary and not a good idea anyway.

Try to apply the change I suggested and then restart nginx.
 
My mistake, i doesn't have shell access so i thought that restarting the server will also restart nginx. Now it's all offline and i'm waiting to see if the staff can resolve (they claim that the server is online but various services confirm that the site is offline).

There is a way to restart nginx and the rest without using shell?
 
Do you have a dedicated server, a VPS or just shared hosting?

After you reboot a server, every service (like nginx, mysql, and so) should restart automatically after booting assuming that everything was properly configured. If not, then you might need to start those services manually (seems to be the case).

Your host is probably right, your server is up (it's responding to pings), the problem is with the critical services not being active.
 
Yeah, i have root access, i simply doesn't have a control panel like Cpanel, Plesk etc.

The support said to me that the server restarted but i have to check the web service status (because now i doesn't have web service). Hope to understand what i have to do...i'm searching...
 
My mistake, i doesn't have shell access(...)

There is a way to restart nginx and the rest without using shell?

Yeah, i have root access, i simply doesn't have a control panel like Cpanel, Plesk etc.

So after all, yes you have root access.

What OS are you running? If you're running CentOS you can run the following command at the console to start nginx:

Code:
service nginx start

If you want to see if other services (for example, MySQL) are running you can run:

Code:
service mysql status
 
Thank you. I have putty but i have to find how to have the SSH credentials...these tasks in the past are done by my collaborator...i will ask the staff.
 
Because i doesn't have the ssh credentials and there aren't a option to create this, i asked the support. They responded me:

Hello, You did install your server and chose your credentials. As you don't remember them, you'll have to modify the credentials by using rescue mode and chrooting yourself on the server in order to get access back. Or, if you didn't install it, you'll have to ask the person you asked for installing your dedibox.
I'm worried to use rescue mod because i haven't tech capacities...if someone can help to do this or do it for me, i would be very grateful for all my life. :-)
 
Is your collaborator dead, incapacitated or are you just on the outs with him/her? They should be able to provide you the credentials to get in.

As an aside - for anyone else reading, this is a VERY good reason if you have someone setting up your box to provide YOU with your own logon credentials and either have sudo set up on your VPS/server, or you having access to the root user password (preferably SUDO priv's).
 
Tracy my collaborator simply disapparead...i don't know where he are. I have asked the staff to reset the credentials or having me new ones. They said me in our previous conversation to use the "Rescue" mode but i'm not a tech user and i doesn't want to create other troubles...If someone can help me to resolve this, i can give him my admin panel credentials...I would thank him for all my life, because this issue is currently ruining my community...
 
Tracy my collaborator simply disapparead...i don't know where he are. I have asked the staff to reset the credentials or having me new ones. They said me in our previous conversation to use the "Rescue" mode but i'm not a tech user and i doesn't want to create other troubles...If someone can help me to resolve this, i can give him my admin panel credentials...I would thank him for all my life, because this issue is currently ruining my community...
It's really not that difficult to do... but it's really only something that I'll do on my servers (VPS/dedi) or the ones at my RGF (really good friends) locations - just in case I mess it up.
You may want to get ahold of @MattW and see what he'd charge you to do this. It would probably be a very reasonable cost.

Instructions can be found almost all over the web to do it.
http://wiki.centos.org/TipsAndTricks/ResetRootPassword
https://fedoraproject.org/wiki/How_to_reset_a_root_password
 
Back
Top Bottom