Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am attempting to use varnish as a front-end proxy to Nginx.

When I attempt to using the following as my vhost configuration:

server {
  listen 8080;
  server_name playwithbits.com  www.playwithbits.com;

  # limit_conn limit_per_ip 16;
  # ssi  on;

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

  root /home/nginx/domains/playwithbits/public;

  location / {

  # 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             / /index.php;

  }

  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;
}

However this stops working when I specify listen 8080 and redirects to the default nginx web root (as specified in virtual.conf), if I remove that line it works as expected and redirects to the correct directory.

Does anyone know why this is happening and how I can set a non-standard port for my vhost so varnish can listen on port 80.

share|improve this question
    
Did you do nginx -t to check nginx config when listen 8080; was specified? –  hangover Jun 14 '12 at 3:04
    
@hangover Cheers, didn't know about that. It returns nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful –  George Reith Jun 14 '12 at 8:04

1 Answer 1

up vote 0 down vote accepted

The problem wasn't Nginx, it was Wordpress. Apparently WordPress redirects itself and you have to put the port extension onto the WordPress Address (URL) setting in the dashboard like so:

http://playwithbits.com:8080

And it works, otherwise WordPress redirects to port 80 causing my default Nginx configuration to kick in.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.