By brancojunio
Hi, I recently set up my kubernetes with ingress. I am able to access my REST through www.abc.com/api for example, however, if I try to access it via abc.com/api or abc.com/ doesn’t seem to reach the server (404).
How can I enable my server to be reachable by both www.abc.com and abc.com?
Below is my ingress definition
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: web-ingress
annotations:
kubernetes.io/ingress.class: 'nginx'
nginx.ingress.kubernetes.io/from-to-www-redirect: "True"
spec:
rules:
- host: www.abc.com
http:
paths:
- path: /
backend:
serviceName: abc-web-service
servicePort: 80
- path: /api
backend:
serviceName: abc-rest-service
servicePort: 80
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello, @brancojunio
The first step will be to make sure that both abc.com and www.adc.dom DNS is pointed to your droplet/server. If that is already configured your can simply redirect www to non-www or vice versa.
Let me know if you have any questions.
Regards, Alex
Hi thank you for your reply!
I believe the domain is already set up to my droplet/server as I can access it via www.abc.com already. How would I go about redirecting any requests to “abc.com” to -> “www.abc.com” ?
Kind Regards Junio
If you’re using Nginx, you could do something like the following within your Nginx config:
server {
....
server_name example.com www.example.com;
rewrite ^ https://www.example.com$request_uri? permanent;
....
}
–
Think different and code well,
-Conrad
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.