Nginx domain resolution 502 gateway - nginx

I have developed a website for a customer, it's currently sitting on a sub-domain on our server and is finished but i now need to carry out testing for eCommerce payments and that means the site needs to move from our sub-domain over to their live domain.
For this, i've created a cPanel account with that domain but because it's live elsewhere, the best way for me to complete the migration before any DNS records are changed on the 3rd party hosting is to be able to access the site on my machine, i edited my local host files (windows) for that reason
Before NGINX was installed on the CentOS server, modifying the local host file would work perfectly and i could access the site only on my machine to finish up the migration, then when finished i'll ask the 3rd party host to change NS to our us, meaning no downtime to their site and a nice migration.
At the moment, even though the host file is changed and a local cmd ping brings up our server, i get a 502 gateway error nginx in the browser, checking nginx error logs i believe it's because nginx server is trying to resolve the 3rd party real host IP address but my machine is set to resolve the server ip version.
Does that make sense? All other sites on the server are working fine through Apache + Nginx but i'm stuck with this problem.
I could simply ask the 3rd party hosting company to change the A record to point to our server but it would mean the client would face some downtime while i finished up the migration.
Any help is appreciated.
Purging nginx cache and reloading
Here is the error message regarding this specific domain in nginx
2019/09/25 10:58:19 [error] 25641#25641: *47 connect() failed (111: Connection refused) while connecting to upstream, client: IP.ADDRESS, server: localhost, request: "GET / HTTP/1.1", upstream: "http://IP.ADDRESS:8080/", host: "www.xxx.co.uk"
The IP address here in this error is the real one where the site is live at the moment.

I found that all i needed to do was edit the /etc/nginx/custom_rules and adding the domain and ip address under "when to specify a domain name". I can now access it locally.

Related

ERR_NAME_NOT_RESOLVED when trying to connect to api through proxy

I have a website, and lately I had to change the web address. When the user first enters "http://name-of_the.website.pl", he is greeted with login screen. This part is working perfectly. As soon as the user enters credentials and hits the login button, the website throws ERR_NAME_NOT_RESOLVED.
The login page is trying to connect to api (deployed in the same docker swarm) through nginx proxy (code below). After inspecting proxy logs I have found this:
2021-11-11 18:02:05 +0000 2021/11/11 18:02:05 [error] 15#15: *192 config.json could not be resolved (3: Host not found), client: 10.0.0.2, server: ~^proxy\.name-of_the\.website\.pl$, request: "GET /config.json HTTP/1.1
The whole thing used to work great before changing the host name.
So everything was fine with my proxy and the website. The reason it did not work was the fact that the website was trying to connect to local proxy while it was on the server somewhere else. All I had to do was add the address of the server hosting the proxy and the rest of the app to hosts file on my machine.

Having Issue with Cloudflare and Nginx proxy manager where it does not connect to my local server. (Error 522/523)

I'm trying for the first time to connect my local server (Synology) through NGINX and Cloudflare so I can access it through my own domain name. I have the proxy host all set up pointing to my local IP address with the port and I have an SSL encryption using Let's Encrypt. The site gives me either a timed out error or unreachable, however one time somehow the site took my to ASUS aicloud which is through my ASUS ac68u router but I was not even pointing NGINX to that.
using cloudflare diagnostic center site it syas the request failed because the web server did not respond.
I'm not sure whether my router is blocking Cloudflare or if there is any other issue going on, would appreciate any help with the matter!

GoDaddy domain in AWS with SSL for Wordpress application Issue

Currently, I am working on a Wordpress application and I am using AWS hosting. My domain is in GoDaddy.com and I have deployed the application in elastic beanstalk. I have created load balancer and also I need to run the application through HTTPS.
I have done my research and I think I found the right way, but it's not working for HTTPS. when I browse on HTTP on port 80, it runs well. Now I am helpless.
Here's what I have done so far:
1) I created a hosted zone on AWS Route 53 for the domain named "example.com". There are two records are created, NS and SOA.
2) Then, in GoDaddy, I added NS records from AWS as Custom Nameservers.
3) After that, I created A record for the domain in the AWS hosted zone, set ALIAS targeted to the Load Balancer of the Elastic Beanstalk environment.
4) Then, I changed the SITE URL from the wp_options table the wordpress application database.
After doing up to this, my application was running in HTTP. But as I want to change it to HTTPS. So,
1) I requested a certificate from AWS Certificate Manager and created CNAME (provided by ACM after requesting certificate) record in the hosted zone.
2) After the certificate is issued, I edited the listener from EC2 >> Load Balancer >> Listener and changed the protocol from HTTP to HTTPS and also allowed port on Security groups.
3) Also, I changed, the SITE URL from WordPress database and changed it from "http://example.com" to "https://example.com" but it was not working.
4) So I went to Elastic Beanstalk >> Configuration >> Load Balancer and added listener. After the environment is saved and restarted, still, the site was not running on HTTPS [ HTTP 408 ERROR IS SHOWN ]. But if I change SITE URL to "http://example.com", it works
I have found a solution, which says to use RedirectURL and set it to server config but I don't want to do that.
I also found this solution which suggest to Export Zone File and import it to AWS hosted zone. But whenever I click Export Zone File(Unix), the file downloaded is shown empty. I tried this for other accounts, still, this problem exists. So I did not do that.
Sorry for the long story, but I really need this help.
I have solved the issue.
In my load balancer port configuration, I previously set load Balancer port 443 and instance 443. here what I need to do is to call the load balancer on port 443 and backend make the backend call on port 80 and enable https on WordPress.
So I kept load balancer port 443 and changed the instance port to 80. After that, on the browser, there was too many redirects error shown. So then what I needed to do is that add $_SERVER['HTTPS'] = 'on' on wp-config. And then everything was running smoothly.
I hope this will help if some

IBM HTTP Server, routing calls to Websphere

Something I have been struggling with for a while, but I'm not able to come up with a proper solution.
This is the situation:
Host 1 - IBM HTTP Server, Customization Toolbox and WAS Plugins
Host 2 - WAS + Application
These are the steps I executed to configure the plugin and propagate it from Websphere:
1. I used the Customization Toolbox, selected the correct WAS Plugins directory and created a new Web Server Plugin
2. I copied the new configureSERVER.bat to my Application Server on Host 2, and configured the current profile.
3. On Host 1, I created an Administrator account.
When I open the WAS-console on Host 2, I can see the actual Web Server, so that went ok. When I select "Generate plugin" and "Propagate Plugin", I get no errors. I checked the HTTP Server, and indeed, my plugin-cfg.xml is neatly created and exists.
To make sure everything is all right, I opened the http://HOST1/snoop on Host 1 and I saw the correct diagnostics. So far, so good.
After that, I deployed my application, which runs on port 9044. However, this application runs on HTTPS, so we need to make sure that the IBM HTTP Server accepts SSL connections. I generated my own selfsigned certificate, imported it in the httpd.conf and restarted the server. (If someone is interested, I'll put some more details on how to do this).
Now, when I open https://HOST1/snoop I can see the diagnostics, which is good news. It means it accepts connections on https and reroutes it to Host 2. But the problem is, I have no idea how to access my application, which is running on port 9044.
Something that puzzles me is the details when I run the snoop-servlet.
When I run it via http (so without SSL), this is the output:
Local address XXX.XXX.XXX.XXX
Local host XXXXXXXXXX
Local port 9080
That is correct, because the port on Websphere is 9080 for that particular servlet. However, when I open https://HOST1/snoop (so, via SSL), this is what being generated:
Local address XXX.XXX.XXX.XXX
Local host XXXXXXXXXX
Local port 9044
So, apparently, 443 is being rerouted to 9044 on the second host, but the Snoop servlet runs on 9443, not 9044 (which is my application). But, then I wonder, why can I access the servlet, if it is running on another port.
So, if there's anyone who can give me some guidance, that would be nice.
This is the VHOST:
<VirtualHostGroup Name="default_host">
<VirtualHost Name="*:9080"/>
<VirtualHost Name="*:80"/>
<VirtualHost Name="*:9443"/>
<VirtualHost Name="*:5060"/>
<VirtualHost Name="*:5061"/>
<VirtualHost Name="*:443"/>
<VirtualHost Name="*:9044"/>
</VirtualHostGroup>
Event though you have 2 ports (I'm assuming you created custom transport chain and assign 9044 port to it), you added that port to default_host, which is visible in the VirtualHostGroup in the plugin. Your application is probably mapped also to the default_host, so it is available using all ports - 9080, 9443 and 9044. Second transport should be visible in the plugin config for your server with port 9044. Since it is also ssl transport plugin could choose that one to route request to your server. There is no way to force plugin to use specific port for communication to WAS for given application.
However you didn't specify what you actually want to achieve? Since your app should now be available via https.

AWS Opsworks, Spring mvc: Unable to open my application on browser

I have deployed my application using AWS Opsworks. I could see that my application has been deployed successfully, however I am not able to open it in a browser. I tried many many combinations of url, but no luck.
On my localhost, I access my application with this url:
http://localhost:8080/app/login.
In opsworks my app name is "bootshop" and it has been deployed successfully.
Now how do i access my login page ???
I tried below urls:
login page: http://xx.xx.xx.xx:8080/bootshop/app/login - 404 Requested resource not available
index.html page: http://xx.xx.xx.xx:8080/bootshop/app/ - 404 Requested resource not available
http://xx.xx.xx.xx:8080/bootshop/login - 404 Requested resource not available
http://xx.xx.xx.xx:8080/bootshop/ - Nothing is displayed on
http://xx.xx.xx.xx - Forbidden
For my EC2 instance, I have custom TCP rule set.. which allows traffic on port 8080 from anywhere.
Your help would be really appreciated.
Thank you
The 8080 address is the internal address that Apache web server uses to communicate with the Tomcat instance. The public address that you should use is 80. Just use the root path of your server to access the application, like this:
http://xx.xx.xx.xx
where xx.xx.xx.xx is your IP address. You can of course use the DNS name if you have any for that IP address.
Make sure that you allow HTTP traffic to port 80 in the security group for the EC2 instance where the application is running.

Resources