Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.1k views
in Q2A Core by

Hi there,

There is a problem in my Q2A that all users are with the same IP.

The server is nginx . I haven't faced this problem before and users used to have different IPs.

I removed all plugins, but still the problem exists.

Is there any idea?

Thanks.

Q2A version: 1.7.4
by
are you using cloudfare?
by
No. We are using Digital ocean DNS Server.

http://ask.bidbarg.com
by
Thanks man.

I was thinking about varnish that I read this post that Scott mentioned: I think you should be turning off Varnish completely for Q2A as it's a dynamic app.

http://www.question2answer.org/qa/28357/varnish-configuration

Do you recommend to configure varnish installation ?

1 Answer

+3 votes
by
selected by
 
Best answer

Despite my earlier answer, using Varnish is actually not a bad idea because there are a lot of static files within the Q2A folder that Varnish can cache, and I think it will bypass any caching for Q2A due to the headers Q2A outputs.

To solve the problem of everyone having the same IP, you can do it at the server level. This guide for nginx looks good. Change the IP to be whatever your Varnish is.

Alternatively, you can override the qa_remote_ip_address function. See docs here. It would need to be something along the lines of

function qa_remote_ip_address()
{
    if ($_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
        return $_SERVER['HTTP_X_FORWARDED_FOR'];
    }

    return $_SERVER['REMOTE_ADDR'];
}

Replace '127.0.0.1' with your Varnish IP.

...