Release IP address in Apache - node.js

I want to run NGINX and Apache Side by Side to use Node.JS with NGINX. The problem is that NGINX is not starting. I have two IPs and at the httpd.conf of Apache I edited the "Listens" to only this:
Listen 1.1.1.1:80
And the default.conf of NGINX to:
server {
listen 2.2.2.2:80 default_server;
...
}
But I'm getting this error when I start NGINX:
Starting nginx: nginx: [warn] server name "/var/log/nginx/access.log" has suspic ious symbols in /etc/nginx/nginx.conf:41
nginx: [emerg] bind() to 2.2.2.2:80 failed (99: Cannot assign requested ad dress)
What am I doing wrong? I searched over the internet and I found how to configure both web servers side by side here: http://kbeezie.com/apache-with-nginx/ and I found this:
To do this you have to make sure Apache and Nginx are bound to their
own IP adddress, In the event of WHM/Cpanel based webserver, you can
Release an IP to be used for Nginx in WHM.
But I don't have cPanel. How can I do this manually?
OBS: 1.1.1.1 and 2.2.2.2 is just an example.

Related

Nextcloud with Traefik - Bad Gateway / Connection Refused

I recently installed Nextcloud over a lamp stack and want to run Traefik in front. For that, I tweaked the apache2 ports.conf to:
Listen: 127.0.0.1:180
. Now I also configured a .toml for Traefik that points to this address.
When I try to open the website, it gives me "Bad Gateway".
Trying to solve the error I searched the Traefik logs and found this:
msg="'502 Bad Gateway' caused by: dial tcp 127.0.0.1:180: connect: connection refused"
Thinking it must be a problem with trusted_proxies I configured Apache to open it's port to the public and also changed the Traefik .toml to see wheter it would work.
It did. That means that Nextcloud definetly accepts my proxy and the proxying works all good.
Problem is, It doesn't work when I configure it on localhost.
The access.log and nextcloud.log show nothing.
Any help?
Many thanks
The solution is simple, but hidden.
Traefik is a Docker container, so normally it can't communicate with services not in the docker network.
The fix is:
ip addr show docker0
Bind Apache2 to this IPv4: (my example) Listen 172.17.0.1:180 and also modify the Traefik Config.
Then Apache2 will listen on the docker0 network which containers have access to.

Nginx Configuration for node Js application + Docker

I have a nodeJS application which is configured as a docker container.For making the application up and running, i was initially using 443 as the port - which gave a message 443 is a privileged port and updated the .yml with 8443 as the port.
Previously i used to give the url like - https://abc-acde.xyz , but now have to give https://abc-acde.xyz:8443 the port also along with domain name.
To resolve this i installed nginx to use it as a proxy to reroute the request.
The nginx config file is configured with the key , certs along with the server details - the configuration snippet of the conf file is below :
server {
listen 443 ssl;
server_name abc-acde.xyz;
ssl_certificate /opt/ssl/abc-acde.xyz/abc_acde_xyz.cer;
ssl_certificate_key /etc/ssl/ssl_signed_certs/abc-acde.xyz.key;
}
After this run the command - systemctl restart the nginx
Hope this configuration will help me to use the url as it was earlier - use without the port
Thanks in advance,
Rahul

rtmp nodejs server config on NGINX _ nginx: [emerg] bind() to 0.0.0.0:1935 failed (98: Address already in use)

I have media server running on port 1935 .
and I have a subdomain: "streaming.foo.com"
I need to configure Nginx to access rtmp://streaming.foo.com
I tried the RTMP Nginx plugin with this blog :
https://www.nginx.com/blog/video-streaming-for-remote-learning-with-nginx/
and configured the /etc/nginx/nginx.conf file.
rtmp {
server {
listen 1935;
application live {
live on;
dash on;
dash_path /tmp/dash; // what is this config??
dash_fragment 15s;
}
}
}
but I get this error from nginx :
nginx[176987]: nginx: [emerg] bind() to 0.0.0.0:1935 failed (98:
Address already in use)
It is RTMP, not HTTP. Nginx is a web server, which can proxy and balance HTTP only. It is not a general proxy server.
Use a general Proxy or Load balancer, like HA Proxy.
You can't have two services listening on the same port.
The common solution is to configure the real service (your media service) on another port (let's say 19350) than configure a reverse proxy on nginix to forward requests from the exposed port (1935 in this case) to the back-end service (19350 in our example).
Sorry but I don't know nginix (I use this config with apache) so I can't help you on how to configure a reverse proxy on it.

Can I stick with server_name directive from nginx or do I still need to set DNS in linux?

I am learning nginx and I have this doubt. Do I need to setup a dns in linux (/etc/resolv.conf) or can I just stay with what nginx uses inside its directive server_name?
You can set nginx to listen to ANY domain pointed to that web server with:
listen 80 default_server;
or you can be specific via server_name. Check Nginx docs
Setting DNS on the webserver itself does not help much..
Adding the entry in your visitor's PC hosts file can override a domain name's A record pointer to the one specified by you.

Nginx is refusing to connect on AWS EC2

I'm trying to use nginx to setup a simple node.js server, I'm running the server in background on port 4000, my nginx config file is
server {
listen 80;
listen [::]:80;
server_name 52.53.196.173;
location / {
include /etc/nginx/proxy_params;
proxy_pass http://127.0.0.1:4000;
}
}
I saved it in /etc/nginx/sites-available and also symlinked it to sites-enabled, the nginx.conf file has the include line already to load files from sites-enabled, then i restarted the service using
sudo service nginx restart
I tried going to 52.53.196.173 and it refuses to connect, however going to 52.53.196.173:4000 with port 4000 it is working, but I'm trying to make it listen on port 80 with nginx, i tried putting my .ml domain as server_name and no luck, and i have the IP 52.53.196.173 as the A record in the domain dns settings, and I'm doing this on an AWS EC2 Instance Ubuntu Server 16.04, i even tried the full ec2 public dns url no luck, any ideas?
Edit: I solved it by moving the file directly in sites-enabled instead of a symlink
There is few possible things. First of all you need to verify that nginx server is running & listening on port 80. you can check the listening ports using the following command.
netstat -tunlp
Then you need to check your server firewall & also the selinux policies. ( OR disable selinux for test )
Then you need to verify that AWS security group configured to access the http/https connections on port 80.
PS : Outputs from the following command & configurations will be helpful for troubleshooting.
netstat -tunlp
sestatus
iptables -L
* AWS Security Group Rules
* Nginx configurations ( including main configuration if changed )
P.S : OP fixed the problem by moving the config file directly into site-enabled directory. maybe, reefer the comments for more info if you are having the same issue.
Most probably port 80 might not be open in your security group or nginx is not running to accept the connections. Please post the nginx status and check the security group
check belows:
in security group, add Http (80) and Https (443) in inbound section with 0.0.0.0 ip as follow:
for 80 :
for 443 :
in Network ACL, allow inbound on http and https. outbound set custom TCP role as follow:
inbound roles:
outbound roles:
assign a elastic ip on ec2 instance, listen to this ip for public.

Resources