Running Apache and NGINX at the same time - apache

I currently have Apache configured and serving content over port 80 and 443.
I wish to serve content over port 8000 using NGINX. I've followed this guide.
in /etc/nginx/sites-available/default I changed
server {
listen 80 default_server;
....
to
server {
listen 8000 default_server;
....
According to the guide, this show allow me to access both
http://my_ip_or_domain:8000
http://my_ip_or_domain:80
at the same time. However, I can access it via port 80, but going over port 8000 returns a ERR_CONNECTION_TIMED_OUT. There's no output in /var/log/nginx/error.log. How can I access it using port 8000?

You have to open the specified port
$ sudo ufw allow 8000
This command would open the 8000 port

Related

How to have both docker and apache using only one port?

I have apache using port 80 and the server is only accessible from outside at port 80 due to firewall. If I run a command like the following, there will be a conflict at port 80. Could anybody show me how to support both application at the same port (two domains are mapped to the same IP, so they can be presumably separated by the domain name)? Thanks.
docker run -d -p 80:8787 quay.io/hemberg-group/scrna-seq-course-rstudio
Run the docker with -p 80:8787 will try to listen a Physical machine. and also the Apache listen the 80 by default.
You can't run more than one programmer to listen the same PORT, but if you just want to a map 80 which you open to the public to the backend server, you can use a Nginx as your delegation server. and then you can run number of servers.
Here is simple config of your Nginx
server { # php/fastcgi
listen 80;
server_name domain1.com www.domain1.com;
access_log logs/domain1.access.log main;
root html;
location ~ \ {
server 127.0.0.1:8787;
server 127.0.0.1:8788;
server 127.0.0.1:8780;
}
}
And your container can run as following way:
docker run -d -p 8787:8787 quay.io/hemberg-group/scrna-seq-course-rstudio
docker run -d -p 8788:8787 quay.io/hemberg-group/scrna-seq-course-rstudio
And your Apache server can be configuration with another PORT, example 8780

How to open a new port in apache

I want to open a new port in apache so that i can accept http requests on the port with http://ip:port
Check Binding to Addresses and Ports:
For example, to make the server accept connections on both port 80 and
port 8000, on all interfaces, use:
Listen 80
Listen 8000
To make the server accept connections on port 80 for one interface,
and port 8000 on another, use
Listen 192.0.2.1:80
Listen 192.0.2.5:8000
IPv6 addresses must be enclosed in square brackets, as in the
following example:
Listen [2001:db8::a00:20ff:fea7:ccea]:80

How to route requests to IIS and/or Apache running on different machines , 1 public IP port 80

This is my setup:
Got a domain : domain.com .
Within my local network I got DNS provided by an active directory box,
an IIS web server running on port 80, host name iis.domain.com,
and this has sites iis1.domain.com, iis2.domain.com
an Apache web server running on port 80, host name apache.domain.com,
with the sites apache1.domain.com and apache2.domain.com.
Within my local network I can access all these sites just fine.
I also have external dns entries for iis1,iis2,apache1 and apache2.
I only have one public IP address and I would like to setup another box which would get port forwarded into the internet ( port forward port 80 and 443 ).
I would like to know what to install on that box and how to configure it.
I have looked at nginx, haproxy and IIS ARR, but I would like to know which of these are the easiest to setup and have the least overhead.
In my mind I would like to specify something like.... ok if it's a request for site iis1.domain.com then take that one to the IIS web server, and if it is for apache1.domain.com then go to the Apache web server.
I would like to go with a Linux solution, but I am not sure which and how to set it up.
Thank you in advance.
P.S.
I saw a possible solution here.
Would something like this work ?
server {
listen 80 default_server;
server_name iis1.domain.com;
location / {
proxy_pass http://iis1.domain.com/;
}
}
server {
listen 80 default_server;
server_name apache1.domain.com;
location / {
proxy_pass http://apache1.domain.com/;
}
}
I would go with haproxy (easiest in my opinion)
just be very careful with your External vs Internal DNS.
the example you have in your question forwards to a dns....which points back to the proxy(external)....which points to the dns...i think you get my meaning.
HAProxy would point to your backends IP address so both internal and external DNS would point to your proxy and get routed fine to its intended backend
the HAProxy config would look something like this :
global
# default globals
defaults
# default globals
frontend http-in
bind YOUR.IP.GOES.HERE:80
bind YOUR.IP.GOES.HERE:443 ssl crt PATH/TO/CERT-FILE.PEM no-sslv3
mode http
option httplog
option httpclose
option forwardfor
acl iis1 hdr(Host) -i iis1.domain.com
acl iis2 hdr(Host) -i iis2.domain.com
acl apache1 hdr(Host) -i apache1.domain.com
acl apache2 hdr(Host) -i apache2.domain.com
use_backend iis if iis1
use_backend iis if iis2
use_backend apache if apache1
use_backend apache if apache2
backend iis
server IIS xxx.xxx.xxx.xxx:80 check
backend apache
server APACHE xxx.xxx.xxx.yyy:80 check
I managed to actually get this to work by installing a linux box with nginx. Port 80 from this box is forwarded into the internet.
In /etc/nginx I added a line to look for other config files -> include /etc/nginx/sites-enabled/*.conf; .
So in /etc/nginx/sites-enabled/ I created one config file, with this info:
server {
listen 80;
server_name apache1.domain.com;
location /{
proxy_pass http://apache1.domain.com;
}
}
server {
listen 80;
server_name apache2.domain.com;
location /{
proxy_pass http://apache2.domain.com;
}
}
server {
listen 80;
server_name iis1.domain.com;
location /{
proxy_pass http://iis1.domain.com;
}
}
server {
listen 80;
server_name iis2.domain.com;
location /{
proxy_pass http://iis2.domain.com;
}
}

Apache port changed but still have to http://localhost:81/dashboard/

I changed Apache port from 80 to 81 because 80 is used by skype.
(I did this
Locate the following lines :
#Listen 12.34.56.78:80
Listen 80
ServerName localhost:80
Replace them by :
#Listen 12.34.56.78:81
Listen 81
ServerName localhost:81)
Long story short, if I do http://localhost:81/dashboard/ it works but I want to only use http://localhost/dashboard/.
I did Xampp -> Config -> Service and Port Settings -> Main port changed from 80 to 81 and SSL port still 443
I'd like to know where's the mistake and how can I repair it.
If you want to open http://localhost/dashboard/ your apache should work on port 80, this is default http port.
So you have to open skype and go to Tools->Options->Advanced->Connection and uncheck "Use port 80 and 443 for additional incoming connections"
The HTTP protocol is set to port 80 by the IANA standards. If you want to use connect to an HTTP server on another port, you must add the port to the URI, as in http://localhost:81/
Now, you can edit /etc/services on a linux box and change 'http' to 81, but this is not recommended, as any other HTTP connections from that host to all servers will all try to connect to port 81, which will break all HTTP clients. (Seriously, this will probably break all kinds of things you don't expect. Just use the port in the URI.)
You can change skype's default port as follow...
Go to Tools -> Options -> Advanced -> Connection and uncheck the box "use port 80 and 443 as alternatives for incoming connections"
Anyway your apache must work on port 80 in order to access http://localhost/dashboard without mentioning a port.

WAMP apache httpd.config and hosts - how to alias localhost to port 8080?

Ok so I configured my apache installation on Windows 7 such that it listens on port 8080 by changing the respective entry in httpd.config.
I was too stupid to realize that now I have to access localhost with :8080 at the end.
Question: is there a way to have my box automagically resolve localhost to 127.0.0.1:8080 ? I don't like haviog to type :8080, and NO I CANNOT change the port to 80, I need that one for firewall.
Thanks
no. hostnames have nothing to do with ports. You'll have to specify the port yourself, or set up a proxy on the usual port 80 that will do the 8080 requests on your behalf. ... or bite the bullet and use port 80 directly and move your firewall elsewhere.