502 Bad Gateway - Nginx - apache

I am receiving:
14201#0: *16 connect() failed (111: Connection refused) while connecting to
upstream, client: 22.222.222.222, server: myserver.com, request: "GET
/favicon.ico HTTP/1.1", upstream: "https://70.88.100.212:7081/favicon.ico",
host: "myserver.com", referrer: "https://myserver.com/"
From a sub domain of my server. Now I've looked and know its not an issue of fpm because this happened when I was installing gitlab in a separate subdomain git.myserver.com. My plesk controller said their was a configuration issue and suggested to run a configure script which than broke my sub domain.
Here is the thing - git.myserver.com is still accessible, it actually just broke the myserver.com instead. I am not to sure what is going on what I have looked through my /etc/nginx/conf.d/*.conf and everything seems correct.
The layout of that file is:
include /etc/nginx/plesk.conf.d/server.conf;
include /etc/nginx/plesk.conf.d/vhosts/*.conf;
include /etc/nginx/plesk.conf.d/forwarding/*.conf;
include /etc/nginx/plesk.conf.d/webmail.conf;
Any suggestions?
UPDATE
70.88.100.212 is the primary server - I have multiple domains pointed there and webspaces built. Those are still accessible fine.

Check if your port 7081 is listening on ip 70.88.100.212.
Try this command :
netstat -ntlpu
In your Nginx conf it should be:
location / {
proxy_pass http://70.88.100.212:7081/;

Related

Why this apache logs showing private ip as client ip?

just want to ask what does this apache logs mean? Although i know some of the meaning but did not really understand this logs line..
10.xx.x.xx - - [08/Dec/2021:08:06:12 +0000] "POST /endpoint HTTP/1.1" 200 511 "-" "PHP Curl/1.9 (+https://github.com/php-mod/curl)" "157.xxx.xx.xxx, 172.70.xxx.xxx"
My Server A (157.xxx.xx.xxx) is calling a http post method to another server B. So in this case not sure what kind of server config causing the client ip infront of the log showing that 10.xx.x.xx (look like private ip?) but my Server A ip is showing at behind as user agent and there is another ip show after my Server A iP (172.70.xxx.xxx)?
I suspect that the ip 10.xx.x.xx maybe is somekind of proxy or gateway ip? Maybe load balancer, nginx, cloudflare or etc?
Can anyone help to explain this? Thanks guys..

400 Bad Request load balancer for Apache servers with NGINX

I am using NGINX as load balancer for Apache WebServers (WordPress). All servers are made with AWS EC2. My config for NGINX:
cat /etc/nginx/sites-available/default
upstream web_backend {
server 35.157.101.5;
server 35.156.213.23;
}
server {
listen 80;
location / {
proxy_pass http://web_backend;
}
}
But after NGINX restart i am access load balancer via public ip and getting an error:
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to
use an ErrorDocument to handle the request.
Apache/2.4.29 (Ubuntu) Server at
ip-172-31-35-36.eu-central-1.compute.internal Port 80
If i refresh page i am getting same error but with another ip in the end (second server’s private ip), so i understand that NGINX do the work and it is Apache problem.
I tried to add 80 port for my servers in nginx config, replace ips with dns and private ip, but it didn’t help. Access log on Apache doesn’t show anything useful, just 400 errors.
What could be the problem?
Don’t use ‘_’ for upstream name, it was the only reason for my problem.
Just check on which ports are the Apache WebServers Running. You have to add those to your upstreams.
E.g.:
upstream web_backend {
server 35.157.101.5:8080; //assuming that your apache webserver is running on this port on this host
server 35.156.213.23:3000;//And a different port on the other.. you still need to add them here if your ports are same
}

hostname not working in another Tomcat server

I have been using
127.0.0.1 localhost
127.0.0.12 www.example.com
in my hosts file in a previous tomcat server.
I downloaded another version of tomcat and the hostname www.example.com is not working it gives me 404 error I think there is a conflict when I tried for example:
127.0.0.1 localhost
127.0.0.12 www.example-s.com
It worked. But, I need my old hostname.
How do I solve this problem?
Please think twice:
You got an 404 error - which is an http status code!
This means that your DNS is working!
The 404 error means that your tomcat could not find the requested resource.
For example:
http://www.example.com/
resulting in 404 error will mean that maybe you have deleted the
Tomcat:webapps/ROOT
directory. Or you have changed the server.xml config.

How to filter requests so that apache handles them and not tomcat?

For various reasons I want to shutdown my server after a certain period of idle time. I am running Tomcat 8.5.29 and Apache2 (not sure the version) on Debian 4.9.88. I wrote a script to look at the last time Tomcat had an access. I only have one app on the server and it is at "http://hostname/source/". My problem is that there are number of webserver vulnerabilities out there and I am getting a constant flow of requests to:
"GET / HTTP/1.1"
"POST /GponForm/diag_Form?images/ HTTP/1.1"
"GET /jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.system%3Aservice%3DMainDeployer HTTP/1.1"
"POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax HTTP/1.1"
What I would like to do is stop anything that doesn't begin with "/source" from even getting to tomcat. I presume that a rewrite or something in Apache can do it, but I am not sure how the requests get to Tomcat in the first place.
Any ideas?
There are two possible ways for requests to reach Tomcat:
The probes send requests directly to the Tomcat port (typically port 8080). You can fix this by restricting Tomcat's listening address to the loopback address, by adding the attribute address="127.0.0.1" to the corresponding Connector element in conf/server.xml. Or you can just block port 8080 in your firewall.
The requests are forwarded from Apache to Tomcat via a reverse proxy configuration in Apache. This means there is a line such as the following in one of the Apache configuration files:
ProxyPass / http://127.0.0.1:8080/
If you add an explicit path prefix to both arguments, you can restrict which requests are passed to Tomcat:
ProxyPass /source http://127.0.0.1:8080/source
This ensures that only requests that begin with "/source" are forwarded to Tomcat.
Some Apache configurations use the AJP protocol instead of HTTP for proxying, but the same reasoning applies.

visualCaptcha error on loading

I can't figure out what else I need to do to initialize visualcaptcha. Running nginx on local server. I'm getting this error in my error log:
2014/11/20 09:00:16 [error] 3567#0: *13 open() "/home/jeff/public/project.com/public/start/6" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /start/6?r=57nri4gpbu HTTP/1.1", host: "localhost", referrer: "http://localhost/"
I'm using php backend with jquery frontend. I've installed everything in the recommended way.
Jeff.
Looking at the error it seems you don't have the php server running in the right place, or accepting connections properly.
It seems your static server (which looks for files in /public/*) is trying to show start/6, when that should be hitting app.php or index.php (not sure if you are running the demo or coding something yourself).
I'll need more details as to your current file structure and virtualhost/server config in order to help you spot where the error is.