I have setup and known to work some sites on my server. One of these sites using https connection hence it uses following server configuration:

server {
        server_name ceremcem.net www.ceremcem.net; 
        listen 80; 

        rewrite ^ https://$server_name$request_uri? permanent; 
        #return 301 https://$host$request_uri;

It redirects all http connections to https.

Everything was working correctly till some days ago.

Now all sites I have have been forwarding to https://ceremcem.net. I have deleted this configuration file, reloaded nginx but problem still exists. All sites in this server are forced to use https connection, and redirect to ceremcem.net. There is no such redirection in none of the files:

root@server:/etc/nginx/sites-enabled# grep https *

How can I debug the problem?

root@server:/etc/nginx/sites-enabled# nginx -v
nginx version: nginx/1.6.0
root@server:/etc/nginx/sites-enabled# uname -a
Linux server.aktos-elektronik.com 3.13-1-amd64 #1 SMP Debian 3.13.10-1 (2014-04-15) x86_64 GNU/Linux

1 Answer 1


Answering to how you can debug the problem:

  1. I usually use grep -FHnir https ., since this will make a non-regex, case-insensitive, recursive grep that will include file names and line numbers in the output.

  2. Have you changed anything recently? Upgraded nginx, added a new virtual host on nginx, etc?

  3. Can you show us an example of a server { } block from a virtual host that is experiencing issues? The contents of nginx.conf could also be helpful.

  4. Another thing you could do: curl -iL http://someothersite.com. If the rewrites are resulting in client-side redirects, you will be able to follow them.

  • 1
    I used curl and find out that I have been messing up with my recently changed modem. I have used DMZ forwarding (all ports) and a manual port forwarding entry for the 443. port. But apparently it was not forwarding port 80. When I use http://ceremcem.net, it was forwarded to https://... BUT the rewriter was not Nginx, it was the modem! I had manually entered a port forwarding rule for 80. port and everything turned to normal. Thank you.
    – ceremcem
    Commented Jul 17, 2014 at 5:22
  • Glad I could help! I am curious as to how you found that out through curl. Did you see any impossible redirects coming from your modem, or you guessed it? Commented Jul 17, 2014 at 5:25
  • 1
    I got the headers and headers were not seemed to sent by nginx server. Nginx have no reason to send HTTP 307 header. Then I -kind of- guessed that it might be some other server -the modem-.
    – ceremcem
    Commented Jul 17, 2014 at 5:34
  • Got it. This does mean that we're not talking about mere port forwards, but more like an HTTP proxy in the router. That scares me a little. Make sure you really need that! Commented Jul 17, 2014 at 5:37
  • Yes, scares me too. This (using a standard modem) is a temporary solution, since my pfSense router somehow become out of action.
    – ceremcem
    Commented Jul 17, 2014 at 5:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .