Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - routingMike

#1
General Discussion / Nginx plugin + Cloudflare proxying
October 10, 2019, 03:44:44 AM
Hello,

I currently proxy websites through CloudFlare. While my web applications do not care about incoming IP, I just noticed that nginx is blocking some IPs from CloudFlare.

For example: https://imgur.com/a/2OYnGUp

Two questions here:

1) I didn't (actively) enable anything that should be blocking incoming http requests. I went through as much of the UI as I can but nothing jumped out at me as being active and would ban IPs. Is there some default WAF config somewhere or otherwise what is causing the nginx plugin proxy to block these IPs?

2) These are CloudFlare IPs. Is there a way to configure nginx (via UI) to show these IPs in this case? There is this nginx module: https://support.cloudflare.com/hc/en-us/articles/200170786-Why-do-my-server-logs-show-CloudFlare-s-IPs-using-CloudFlare- and http://nginx.org/en/docs/http/ngx_http_realip_module.html. Is there a recommended way to activate this module and populate the config for nginx?


Thanks!
#2
Quote from: fabian on May 19, 2019, 06:53:26 PM
Example:

Regex: (.*)
New URL Pattern: https://fabian-franz.eu$1
Flag: Redirect

Result:


curl -v "http://fw.test/test.txt"
> GET /test.txt HTTP/1.1
> Host: fw.test
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Sun, 19 May 2019 16:51:55 GMT
< Content-Type: text/html
< Content-Length: 154
< Connection: keep-alive
< Location: https://fabian-franz.eu/test.txt
<
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>


Worked for me! I had misundestood how to properly set this up.
Thank you for the help!!
#3
Ah! I think I did it completely wrong then. I was trying to capture on the domain (example.com) to redirect to www.example.com but it makes sense to capture (.*) on the example..com server and do the redirect to www.example.com

I will try that! Thank you.
#4
Hi,

I finally got around to trying it, and I don't believe it works, at least not as I need it.

Going through the UI then looking at the generated nginx.conf, I see a

> rewrite example.com https://www.example.com permanent;

However the browser doesn't get redirected. Not does the content show up for what would be under www.example.com

Ideally, what I need is more akin to return 301 https //www.example.com$request_uri, so an http 301 redirect.

#5
I naively thought that was specific for paths. Didn't even consider it might work for domains. I'll try it out.
#6
Hello,

I'm trying to use the nginx plugin web interface to create a redirect from non-www to www domains. I might be missing it, but there doesn't seem to be any options to allow me to redirect a domain in either the http server or location. Nothing fancy, just a return 301 (new url);.

Another option I can do is generate the config files directly on disk, since the plugin has facilities to plop your own nginx server blocks but i hesitate to go that route since nginx currently manages generating the SSL blocks for my HTTPS servers, I'm concerned about keeping the two in sync (the web ui vs the manually generated redirect server blocks).

Does anyone know of a way to have nginx generate http redirects for domains?

Any input here?