Caddy not redirecting https:// to https://www - caddy

My Caddy config does not redirect https://example.com to https://www.example.com
However, if I just type http://example.com, it does the redirection correctly to https://www.example.com
Caddy file:
{
debug
email myemail#example.com
}
example.com {
redir https://www.example.com{uri}
}
www.example.com {
tls {
on_demand
}
reverse_proxy docker:7000
}

Related

Cannot ping domain without subdomain with Caddy

I have a domain example.com that i am trying to set up with caddy as a reverse proxy as well as static file host.
I have set up an a record pointing to the host ip with a wildcard record *
In my caddyfile i have this:
example.com {
root * somefiles
file_server
}
subdomain.example.com {
reverse_proxy 127.0.0.1:someport
}
I disabled ufw for this test
When i access example.com, i get an NXDOMAIN error. Pinging example.com gives me a host not found exception. However, accessing subdomain.example.com works fine and pinging it reveals the underlying ip
Anyone know the cause of this?

Caddy - How to disable https only for one domain

I have a config file for Caddy v2 like in below:
sentry.mydomain.ru {
reverse_proxy sentry:9000
}
tasks.mydomain.ru {
reverse_proxy taiga-proxy:80
}
ain.mydomain.ru {
reverse_proxy ain-frontend:80
}
Caddy makes https for every domain but I need to make disable "https" only for ain.mydomain.ru.
How to do it?
Caddy serves http traffic only if you prefix the domain with http scheme.
Here is the modified Caddyfile:
sentry.mydomain.ru {
reverse_proxy sentry:9000
}
tasks.mydomain.ru {
reverse_proxy taiga-proxy:80
}
http://ain.mydomain.ru {
reverse_proxy ain-frontend:80
}
Reference: https://caddy.community/t/is-there-any-way-to-disable-tls-from-the-caddyfile/8372/2
domain:80 or ip:80 will help you access your site on http mode. The example below ain.mydomain.ru will be available only on http. Also ensure tls directive is disabled for the domains you want to access via port 80 using http protocol only.
sentry.mydomain.ru {
reverse_proxy sentry:9000
}
tasks.mydomain.ru {
reverse_proxy taiga-proxy:80
}
ain.mydomain.ru:80 {
reverse_proxy ain-frontend:80
}

How to redirect all traffic to non www https with .htaccess

I have domain registered in ovh. My site files are stored in folder called "www" in root directory. It was original ovh setup. A few days ago I discovered that i can use let's encrypt ssl certyficate. Now I have these addresses:
example.com,
www.example.com,
https://example.com,
https://www.example.com
I want to redirect:
example.com
www.example.com
https://www.example.com
to:
https://example.com
via .htaccess 301 redirection
I tried a lot of sample htaccess redirections from this and other sites. Non of them work perfectly for me.
For example redirection from example.com to https://example.com was ok, but from www.example.comtake me tohttps://www.example.com/wwworhttps://www.example.com with browser warning "unsafe content".
It is harder than i thought.
If you're using wordpress, you could install a simple pulgin called Really Simple SSl which will automatically do this redirection.

301 is not working on nginx server

A magento website transferred to Nginx and my 301 redirects are not working here.
Previous URL:
www.domain.com/store/food/two-year-supply-of-glide-r-chow-glide-a-mins.html
New URL:
www.domain.com//two-year-supply-of-glide-r-chow-glide-a-mins.html
Initially my .htaccess was
Redirect 301 /store/food/two-year-supply-of-glide-r-chow-glide-a-mins.html /two-year-supply-of-glide-r-chow-glide-a-mins.html
and now I have convert it to Nginx server format i.e.
location /store/food/two-year-supply-of-glide-r-chow-glide-a-mins.html {
rewrite ^(.*)$ /two-year-supply-of-glide-r-chow-glide-a-mins.html redirect;
}
Which is not working.
You conversion looks fine to me. sometime nginx server ignore .htacess file try with a new file named as nginx.conf and put your all htacess conversion in this.
Edit
# nginx configuration
location /store { rewrite ^/store/food/(.*)$ /$1 redirect; }
I think this might help you.

RedirectMatch 301 equivalent in Nginx

I'm a Apache user trying to use Nginx and I really can't understand how to convert RedirectMatch 301. Can someone give a better explanation of how it works?
.htaccess version:
RedirectMatch 301 /(tf2|cs|dota2|portal|hl|l4d|steam)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_/]+) /$1/$3
My try on /etc/nginx/sites-available/default file:
server {
rewrite "^/(tf2|cs|dota2|portal|hl|l4d|steam)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_/]+)" /$1/$3 last;
}
It's intend to redirect for eg. mysite.com/tf2/this-will-be-removed/this-will-not/ to mysite.com/tf2/this-will-not/
Thanks!
It should be :
server {
server_name mysite.com;
location / {
rewrite "^/(tf2|cs|dota2|portal|hl|l4d|steam)/([-\w]+)/([-\w/]+)$" /$1/$3 permanent;
}
}

Resources