Nginx server 301 Moved permanently

user145714 asked:

When I did a curl -v I received this result:

* About to connect() to port 81 (#0)
*   Trying ip... connected
* Connected to (ip) port 81 (#0)

> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-unknown-linux-gnu) libcurl/7.19.7 NSS/ zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host:
> Accept: */*
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.2.4
< Date: Fri, 16 Nov 2012 16:28:19 GMT
< Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Pingback: The URL above/xmlrpc.php
< Location: The URL above

Seems like this line in my fastcgi_params is causing grief.

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

If I remove this line , I get HTTP/1.1 200 OK but I get a blank page.

This is my config:

server {
       listen 81;
       root /var/www/html/site;
       access_log  /var/log/nginx/access.log;
       error_log   /var/log/nginx/error.log;
        index index.php;
        if (!-e $request_filename){
                rewrite ^(.*)$ /index.php break;

    location ~ \.php$ {
                fastcgi_pass;  # port where FastCGI processes were spawned
                fastcgi_index index.php;
                include /etc/nginx/fastcgi_params;
                include /etc/nginx/mime.types;

    location ~ \.css {
                 add_header Content-Type text/css;

    location ~ \.js {
                add_header Content-Type application/x-javascript;


This config works with ip and port 80. But now I need to use a domain name and port 81, which doesn’t work. Could someone please help. Thanks.

My answer:

This is a problem with your WordPress configuration, not your nginx configuration. If you really mean to run the server on port 81, then you have to modify the URL in your WordPress options.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.