Access to site sever directly from a selected country

hi there
i just want my users from a country that my server is on that country , reach my server directly and bypass Cloudflare
for example if my server is in dubai , users from UAE(country) connect automatically to server
is there any way so i can setup this ?

You’d need to set up an additional host which is not proxied. Then, you’ll need to redirect visitors from the target country to that host. There is probably some way to accomplish this with workers, but the easiest way would be to implement this server-side.

ok would you please tell me in details
what should exactly be done on the server so i can reach my requirements??
its important to say im using a shared host

You’ll need a web developer to write up some code to do this. It looks possible with .htaccess:

Or with some sort of Javascript in Workers.

Either way, your server may need a special subdomain, like that’s an alias for the main site you can use for direct connections.

Is there a particular reason you don’t want specific users going through Cloudflare?

yes its because of my users from iran cant access correctly to my website and as my server is in iran so i want to direct the connection
its wierd that some IP’s in iran can access correct and some of them cant access and see images

In that case the aforementioned solution wouldnt work as they’d still need to access your proxied host, which apparently does not work for them. You could still have a dedicated host for them and give them a different URL. Alternatively you could send everyone straight to your server and only redirect non-Iranian visitors to your Cloudflare proxied URL.

1 Like

ok thanks for your response. so with this information whats your advice??
i think your last sentence is good to send every one straight and only redirect non-iranian
if i want to do so , its possible through .htaccess ??

.htaccess is just an on-the-fly server configuration for Apache. So assuming you are using Apache, yes you could do that via the configuration, and so implicitly .htaccess.

You should just be aware that by doing so your IP address will be revealed. If that is not of concern you can go ahead.

Now the tricky part is figuring out which of your visitors aren’t from Iran without the benefit of Cloudflare’s Country Code header.

True! Some fancy IP-to-country mapping might help though.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.