Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:04:51+00:00 2026-06-10T12:04:51+00:00

I am running Varnish 3.0 in front of an Apache2 + PHP 5.3 server.

  • 0

I am running Varnish 3.0 in front of an Apache2 + PHP 5.3 server. My problem was that Varnish threw many 503 Service Unavailable errors, so I added a workaround, saying something like:

if http_code = 503 and cookie(REDIRECTED) = false
  set-cookie REDIRECTED=true
  header 307 redirect to same page // try again, maybe this time it doesn't fail
else if http_code = 503 and cookie(REDIRECTED) = true
  header 503 // we tried, but the server doesn't want to

This is a sketch in pseudo-code of the main idea what I did. However, when the 307 redirect is being made, the cookies sent by apache in the Set-Cookie header, are not sent. My main concern is that the PHPSESSID cookie isn’t being sent. If I don’t get an 503 error and Varnish doesn’t have to make the redirect, all works fine. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:04:53+00:00Added an answer on June 10, 2026 at 12:04 pm

    Hopefully I understood your question right. I don’t really see how PHPSESSID is related to handling the 503 errors, but you don’t need to use cookies at all to re-try a request.

    You can use restarts in Varnish to accomplish what you are trying to do. For instance to try the request 2 times you could do:

    sub vcl_error {
        if (obj.status == 503 && req.restarts < 2) {
            return (restart);
        }
    }
    

    This should provide the functionality you are looking for without touching the cookies.

    This is obvious, but I will say it anyway: what you really should do is find out what is causing the 503 errors. If they are not coming from the backend, they are caused either by timeouts or a problem with the Varnish configuration. Keep an eye on your Varnish log for “TxStatus c 503” lines and see what’s going on with the requests.

    Update regarding the possible cause of 503 errors:

    Apparently you are receiving the 503 errors on POST requests (i.e. when a user tries to log in). This can occur if posts are done over slow links or the connection is terminated by the client for some other reason before POST body is completely transferred. However this should not show up as no error recorded in varnishlog. You might want to give the following a shot in any case to see if it fixes your problem.

    Varnish defaults to return(pass) for POST requests, but this doesn’t work as expected in all cases (see Varnish ticket #849 for more information).

    We have opted to pipe all POST requests and append X-Forwarded-For to the requests as well. Here’s the relevant VCL:

    # PIPE all POST requests
    
    sub vcl_recv {
     if (req.request == "POST") {
       return (pipe);
     }
    }
    
    # Set XFF for piped requests
    
    sub vcl_pipe {
      set bereq.http.Connection = "close";
      set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;
      if (bereq.http.x-forwarded-for) {
        set bereq.http.X-Forwarded-For = bereq.http.X-Forwarded-For + ", " + client.ip;
      } else {
        set bereq.http.X-Forwarded-For = client.ip;
      }
      return (pipe);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running SQL Server 2008 (not R2). I have a few reports that have URLs
Running jetty server with ant script that starts it. I keep getting this exception
Running into a problem where on certain servers we get an error that the
I have Varnish running on IP Foo with IP Bar as default backend. I
Running Solr on Tomcat 7 on Win 2008 Server. I am looping through a
Running my script through Devel::NYTProf showed that the following portion of code took up
I have a problem with my server redirecting http://www.mylesgray.com:8080/ -> http://www.mylesgray.com/ . Here are
Running IIS 6 with a main website using .net 4. I have many sub
Running zookeeper 3.3.3. I have a znode that I am just trying to list,
I have a Rails app that is running on port 8080 that I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.