Apache redirects port with nginx proxy - nginx

Whenever I use my nginx proxy which is hosted on the same server as my apache2 server it will redirect straight to the apache2 port instead of staying on the nginx. I've tried setting the host variable to $host:apacheport and it didn't help. Can anyone help me fix this?
(Ex domain.com redirects to domain.com:1234)

Related

How to redirect nginx to another port using proxy settings?

When I go to [myIpAddress:80] in other computers browsers I want to redirect it to localhost:54321 on my server. How to do this?
this is my nginx default file. please complete it to redirect localhost:54321 when I send request to port 80 http port.
Please edit this file and give me the edited configuration.
Check the link below
My Default Nginx Configuration

How can I redirect NON HTTP/NON HTTPS traffic to a specified IP with Nginx?

I have website and some game server.
I have domain which I connect to Cloudflare.
I want to redirect non http/https traffic to my server IP because when I try to connect to server with domain I can't do this because of Cloudflare proxy.
Maybe it can be done differently?
I use Nginx.
Cloudflare has its own SSL configuration.
There are 4 options for you:
Off disables https completely
Flexible Cloudflare will automatically switch client requests from HTTP to HTTPS but it still points to port 80 on your nginx server, should not configure SSL on nginx in this case.
So the only options for you are Full or Full Strict (more restricted on the cert configured on nginx, must be a valid cert).
With Full you can configure your nginx with a self-signed SSL and let it go. Cloudflare will handle the part between client and its proxy server.

Http on apache to https on nginx

How do I redirect my http://example.com website on apache to https://www.example.com website on nginx.
Thanks
Firstly you must add A record (in DNS config) for www.example.com transfer for nginx website. But it not OK for clients and SEO overall. And the second A record must be for example.com on apache website.
After or before adding of DNS record you must check Apache config for example.com - apache website must work for example.com only.

Failed redirect from naked domain on SSL

I have recently installed SSL on my AWS hosted wordpress site and my named domain is no longer working.
https:// example.com, https:// www.example.com, www.example.com are all working as expected.
example.com is not working. example.com throws a connection refused error.
The Setup:
Wordpress hosting is on a single AWS EC2 installed off the bitnami AMI. EC2 sits behind a classic load balancer.
SSL certificate is managed on AWS certificate manager and was issued to *.example.com, example.com and www.example.com
DNS uses route 53: www.doamin.com and domain.com have A records that point to the same load balancer alias
.htacces has been modified with RewriteRule ^(.*)$ https://example.com/$1 [R,L]
What do I do to get this working?
HTTPS does work, so the issue is not DNS. You mention a load balancer. The Connection Refused error indicates that your request is not making it to the load balancer or being accepted by the load balancer.
Check your security groups for the load balancer and ensure port 80 inbound is allowed.
Check your load balancer has a listener on port 80.
If you have modified the NACL's (Network Access Control Lists) on the public subnets of the loadbalancer, then you will need to allow 80 inbound and everything outbound. The default NACL rules already allow this.
As an aside, I note that you are terminating SSL on the load balancer (because you are using an ACM cert). Depending on your configuration, this may mean that you are forwarding requests to your web server unencrypted on port 80. If so then your re-write rules will not correctly detect the use of HTTPS. AWS has some documentation explaining this in more detail.

ERR_CONNECTION_REFUSED when we use https:// without www

Suppose, https://www.domain.com is my website URL
When I have set redirection from
http://domain.com
or
http://www.domain.com
to
https://www.domain.com
it is working perfect
but when i am opening website with https:// and without www then it is giving
ERR_CONNECTION_REFUSED error.
Any response will be highly appriciable.
This error (Error 102) means Azure is not listening on port 443 or there is a firewall which rejects your connection on the host.
So add Listen directive to your configuration:
Listen 443

Resources