-1

I have a problem with both RoundCube and phpMyAdmin. I have varnish running on port 80 and nginx running on 8080.

When I go to phpmyadmin.domain and log in, it will redirect me to phpmyadmin.domain:8080.

When I go to webmail.domain and try to log in, it keeps reloading the login page unless you go to webmail.domain:8080 and log in, then it will work.

I have tried

    port_in_redirect off;

but it still seems to need 8080.

Nginx config for phpmyadmin:

server {
    listen       8080;
    server_name  phpmyadmin.domain.name;

    port_in_redirect off; 

    access_log  /var/log/nginx/phpmyadmin.access.log;
    error_log  /var/log/nginx/phpmyadmin.error.log;

    root   /var/www/phpmyadmin.domain.name/;
    index  index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

Nginx config for webmail:

server {
    listen      8080;
    server_name webmail.domain.name;
    root        /usr/share/roundcubemail;

    port_in_redirect off;

    # Logs
    access_log  /var/log/roundcubemail/access.log;
    error_log   /var/log/roundcubemail/error.log;

    # Default location settings
    location / {
        index   index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    # Redirect server error pages to the static page /50x.html
    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        root /var/www/html;
    }
    #error_page  404              /404.html;

    # Pass the PHP scripts to FastCGI server (locally with unix: param to avoid network overhead)
    location ~ \.php$ {
        # Prevent Zero-day exploit
        try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

        fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include         fastcgi_params;
    }

    # Deny access to .htaccess files, if Apache's document root
    location ~ /\.ht {
        deny  all;
    }

    # Exclude favicon from the logs to avoid bloating when it's not available
    location /favicon.ico {
        log_not_found   off;
        access_log      off;
    }
}
brad7928
  • 11
  • 3
  • Your nginx listen to port 8080, so anything that listens port 80 has nothing to do with nginx and nginx has nothing to do with it. – Alexey Ten Mar 04 '15 at 09:59
  • @AlexeyTen I understand that, but everything else seems to be able to pass through fine without requiring the 8080 port being shown in the URL, so why is RoundCube and phpMyAdmin any different? – brad7928 Mar 04 '15 at 23:42
  • Propably it's php send this redirects. Check what is in fastcgi_params file. There should be something like server_port. Try to replace it with 80 – Alexey Ten Mar 05 '15 at 06:30

1 Answers1

1

As AlexeyTen mentioned above, php server port was the problem in /etc/nginx/fastcgi_params I changed:

fastcgi_param SERVER_PORT $server_port;

to:

#fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PORT 80;

and it has resolved my problems!

brad7928
  • 11
  • 3