pump.io port in URL - node.js

I just installed pump.io on my server (CentOS 6.5, x64), and I also have a Ghost blog (blog.mydomain.example) hosted on my server, which is behind Apache. The home page of my site is a static html page.
Now the problem is: when I visit social.mydomain.example, I'll be redirected to my blog (the URL is still social.mydomain.example). I can only visit pump.io by entering social.mydomain.example:31337 and the user link would be something like social.mydomain.example:31337/test. How can I make the port number disappear in the URL and visit pump.io via social.mydomain.example? Thanks!
Here are some configurations on my server:
Apache host settings:
<VirtualHost *:80>
ServerName blog.mydomain.example
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:2368/
</VirtualHost>
<VirtualHost *:80>
ServerName mydomain.example
ServerAlias www.mydomain.example
ProxyRequests off
DocumentRoot /var/www/html
</VirtualHost>
How I installed pump.io
cd /usr/bin/nodejs/
git clone https://github.com/e14n/pump.io.git
cd pump.io
npm install
cd pump.io/node_modules/databank
npm install databank-mongodb
cd /usr/bin/nodejs/pump.io/bin
forever start pump
My pump.io configuration
cat /etc/pump.io.json
{
"driver": "mongodb",
"params": {"host": "localhost"},
"secret": "pumpiol",
"noweb": false,
"port": 31337,
"site": "social.mydomain.example",
"owner": "NetAdmin",
"ownerURL": "http://mydomain.example",
"hostname": "social.mydomain.example",
"nologger": false,
"serverUser": "pumpio",
"uploaddir": "/var/local/pump.io/uploads",
"debugClient": false,
"firehose": "ofirehose.example"
}
My iptables configuration
-A INPUT -m state --state NEW -m tcp -p tcp --dport 31337 -j ACCEPT
My DNS zone file:
A (Host)
Host Points To
# M.Y.I.P
CName (Alias)
Host Points To
blog #
social #
www #

OK since I got the badge of Tumbleweed, I'm encouraged to provide an answer.
For those like me who want a self-own microblogging service along with a blog, a home page (multiple sub-domains with one host server), while don't want the port number shown in the url, I recommend storytlr. It meet all my needs and it has been easily installed on a CentOS server (mine is 6.5, x64). The latest stable release is 1.20. Simple and direct.

What you're doing is running pump.io behind a web server. The simplest and recommended installation is to run pump.io standalone, if you have the extra IP address for it.
The other common way of running pump.io is to put it behind nginx. Apache is not as well suited to this kind of reverse proxying/websockets work. Many of us have started out trying pump.io behind Apache and switched to nginx because it's easier to configure and troubleshoot.
See http://jrobb.org/moving-my-pump-home.html or http://sjoberg.fi/blog/pumpio.html for examples.

Related

Should I use domain name for my docker application instead of IP address?

I have a web application running in a Linux Ubuntu 20.04 (through docker) and I'm wondering if is valid use an alias for the users access this application.
Today they access using the server's IP (ex. 192.168.1.1) but the user are non-techs and I want mitigate the chances of error. By using a domain name (an alias), I think the chances of error are going to decrease.
I've no idea if is possible and if is a valid question xD.
Any thoughts will be really helpful.
It is preferable to use domain name for user applications.
Usually, instead of exposing a docker application directly to port 80/443, you'd setup a reverse proxy (gateway) in front of a docker application. Something like Apache or Nginx. You probably already have either of them on your current setup.
You just need to setup proper virtual host configurations.
For example, if you're using Apache:
<VirtualHost *:80>
DocumentRoot "/var/www/your/path"
# Assuming your domain name is internal.foobar.com
ServerName internal.foobar.com
# Assuming your docker application is binded to port 8080
ProxyPass "/" "http://127.0.0.1:8000/"
ProxyPassReverse "/" "http://127.0.0.1:8000/"
</VirtualHost>
If you're using Nginx:
server {
listen 80;
server_name internal.foobar.com;
root /var/www/your/path;
location / {
proxy_pass http://127.0.0.1:8000/;
}
}

Issues getting Apache VirtualHost to properly Map

I'm setting up a docker container on a linux server and I'm trying to set up a VirtualHost so that when I visit the domain I own it will show that website.
I have a DNS record on my domain to use the IP address of my linux server, and I installed apache on there to test and it worked properly.
If I start my container with
docker run -dit --name web-app -p 8080:80 web-image
I can go to mydomain.com:8080 and see my website, but it doesn't work if I just navigate to mydomain.com.
My VirtualHost stanza in httpd.conf is
<VirtualHost *:80>
ServerAdmin admin#mydomain.com
ServerName mydomain.com
ServerAlias mydomain.com
DocumentRoot /usr/local/apache2/htdocs
</VirtualHost>
The only thing I can think is that I need to update my domain DNS definition to accept the Docker Container IP address?
Is there something I'm missing?
It's quite obvious, that the website is available on port 8080, but not port 80, since you define -p 8080:80. You need to expose port 80 instead.
docker run -dit --name web-app -p 80:80 web-image

Provision headers are shown error in google chrome when using apache virtual host

I have to tomcat servers running in my server. And I wanted to do a virtual host routing. So initially I tried it with one tomcat which is running in 8081 port and ajp port enabled to 8011 in the tomcat server.xml file
My conf file in the /etc/apache2/sites-available/mydomain_name.com.conf looks likes this
<VirtualHost *:80>
ProxyRequests off
ProxyPreserveHost On
ServerName mydomain_name.com
ServerAdmin ubuntu#mydomain_name.com
ProxyPass / ajp://localhost:8011/
ProxyPassReverse / ajp://localhost:8011/
</VirtualHost>
Then I did
sudo a2ensite mydomain_name.com.conf
sudo service apache reload
Every thing went find, no issues. And I also ensured the port 8011 is listening.
But when I try to access the server from my personal laptop, the request is blocked by Google chrome.
I have enabled these configurations in the server too.
sudo a2enmod proxy
sudo a2enmod proxy_ajp
sudo a2enmod proxy_http
sudo service apache2 restar
Have anyone has came across this issue ? Shedding some light would be really helpful. Because I have done some thing similar 1 year back, then this issue did not occur, and I'm only trying to direct it to the tomcat home page. Which is a bare minimal page.
After several frustrating hours found the issue. Hope this might help if any one came across this same issue.
Although the port 80 was opened via the aws management console security groups, internally the ports were firewall protected by the ip tables. So by removing the ip-tables entry for the port 80 I was able to make the virtual host work.

How to build a simple website into a embedded Linux using Apache and Yocto?

I like to build a demo of a website running on an eval board from ATMEL. For this eval board I am building an Linux by the use of Yocto. For handling the website the apache webserver should be used.
I got the apache2 recipe build and installed, as well as my simple website. But I failed to set up the apache configuration right.
My system has two ethernet ports eth0 and eth1. Eth0 is configured to the IP 1.2.3.4 and eth1 to dchp. The index.html should be accessed through eth0. Maybe it is possible to have an literal like "mywebsite" to access it.
The website files are put in to the custom dir: /var/www/html/
Actual I am copying an virtual host config(myweb.conf) to /etc/apache2/sites-available/. It looks like:
# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
ServerName mywebsite
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
The yocto recipe unzips the index.html which is in myweb.zip and installs the virtual host config. The code looks like:
SUMMARY = "myweb"
SECTION = "test"
LICENSE = "CLOSED"
SRC_URI = "file://myweb.zip \
file://myweb.conf \
"
DEPENDS = "apache2"
S = "${WORKDIR}"
WWWdestPATH = "/var/www/html/"
do_install () {
install -d ${D}${WWWdestPATH}
cp -r ${S}/myweb/* ${D}${WWWdestPATH}
install -d ${D}/etc/apache2/sites-available/
cp ${S}/myweb.conf ${D}/etc/apache2/sites-available/myweb.conf
}
FILES_${PN} += "${WWWdestPATH}*"
FILES_${PN} += "/etc/apache2/sites-available/*"
Any ideas how to modify the files to get the website started?
Stefan,
If I understand you correctly you want to host web pages on the ATMEL board for clients connecting via eth0. I can't see anything obviously incorrect in your virtual host definition.
Adding mywebsite as ServerName tells Apache that that is the name for this specific virtual host - but clients still need to be able to resolve that name. Please note that if you only have a single site on the server the name doesn't matter in the Apache configuration - what matters is the DNS configuration. As long as the hostname resolves to the web server any request for any hostname would get the default site - unless there is a virtual site with a name that matches the requested host name.
What I would do is to start from the web server end and work your way out from there:
If you have included telnet in your build you could for instance access the web page directly from the command line to make sure that it answers. Do this on the ATMEL board (e.g. via ssh or if you have a display+keyboard):
telnet localhost 80 <ENTER>
GET / HTTP/1.1 <ENTER>
Host: mywebsite <ENTER><ENTER>
If that returns your web page then the web server is configured correctly.
Make sure that you can reach the ATMEL board from your client. On the client:
ping 1.2.3.4
If this doesn't work you need to put the client on the same network as the eth0 interface by setting it manually on the client or by adding a DHCP server on the ATMEL board, bound to eth0.
Make sure that the client can resolve the mywebsite host name. On the client:
ping mywebsite
If this doesn't work you need to add a DNS service (e.g. bind) to your image or, for a quick test, add the following line to the /etc/hosts file on your client (c:\windows\system32\drivers\etc\hosts if you are running Windows):
1.2.3.4 mywebsite
Hope that helps.

Create link to Wordpress blog from MEANJS app in the same domain nginx

I am running a Node app at port 3000, which my Nginx server is successfully redirecting to from port 80. But within my Node app I have a wordpress blog which I am running using Apache at port 8080. I am unable to link node app to this blog, and keep getting a 404 error.
I had used:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
Here are the things I have done:
Set up my nginx to redirect to 127.0.0.1:8080 on /blog
server {
location / {
proxy_pass http://127.0.0.1:3000;
}
location /blog {
proxy_pass http://127.0.0.1:8080;
}
}
Pointed my Apache to 8080 to root folder of wordpress at /var/www/htdocs
Within my MEAN app link blog with a target=_self
[NOTE: have also tried ng-click="$event.stopPropagation()" and window.location= '/blog' on ng-click]
Now I keep getting redirected to /blog#!/ and given a 404 error within my app itself. Being my first MEAN app, I am a little new to this, so please bear with me if the answer is obvious, cause I fail to see it.
EDIT: Apparently I haven't set up Apache correctly as I cannot access anything at port 8080, when trying to access myip:8080 from the outside
EDIT 2: So now I can successfully access the blog at port 82, and have set up my wordpress site. Now nginx is not detecting the url mydomain.com/blog as it is not redirecting it and Node continues to handle by url giving a 404 error, though if I enter mydomain.com:82 it takes me there, which then changes to the ip:82 format on clicking on anything. :(( This is really driving me up the wall
So I finally solved this one :). Here is my solution in case some one wants to add a Wordpress blog to their MEAN JS app.
My set up is a Debian OS running an Nginx server as the main web server, so at port 80. My node app is set up to run at port 3000, and even though I don't think a third server is needed, I went with it anyways, an Apache server at port 82, for my Wordpress blog.
Now before I added the blog, I was redirecting all traffic from port 80 to 3000 by setting a prerouting rule in iptables
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
This has to be deleted before your Nginx can handle anything. So I went to my NAT iptables, and deleted this rule by line number. I did the following
iptables -L -t nat –line-numbers
To see my list of prerouting rules and get the correct line number and then deleted it with
iptables -t nat -D PREROUTING MYRULELINENUMBER
After this I set up my nginx server by adding a file example.com in sites-available folder at etc/nginx/sites-available/
upstream app_node{
server 127.0.0.1:3000;
keepalive 8;
}
server{
listen 0.0.0.0:80;
server_name example.com;
access_log /path/to/log;
location / {
proxy_pass http://app_node;
//Other lines here do a basic Nginx setup search you can find them all
}
location /blog{
proxy_pass http://127.0.0.1:82;
}
After this I linked this file to my nginx/sites-enabled to get it going
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
Now my nginx is all set up, moving on to my blog. I first installed Wordpress in var/www/myblog/ and then went to my etc/apache2/sites-available folder
If you don't know how to install Wordpress on debian, look at the end of this post, I have attached all the links I used
My example.com file in apache2/sites-available
<VirtualHost *:82>
ServerName example.com
DocumentRoot /var/www/myblog
Alias /blog /var/www/myblog
<Directory /var/www/myblog>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
I would suggest copy default under sites-available and customize for your own domain.
Finally in my angular file, I linked blog with a simple
BLOG
Nginx will route you to Apache on clicking this link, you set up your blog by visiting mydomain.com/blog/wp-admin, make sure your SiteUrl and Wordpress Url are set up correctly, I personally spent too long fixing this as I messed up here.
If you run into any trouble try running a
wget example.com/blog
It will show you exactly what is happening when the request is received by your nginx server. I had a stray rewrite in my nginx server file causing a 301 error, so make sure your correct examples.com file is available in sites-enabled.
Links that helped immensely:
https://www.binarylane.com.au/support/solutions/articles/1000017339-installing-wordpress-on-debian-ubuntu
http://lubos.rendek.org/remove-all-iptables-prerouting-nat-rules
http://nginx.org/en/docs/http/ngx_http_proxy_module.html
https://askubuntu.com/questions/162866/correct-permissions-for-var-www-and-wordpress
https://www.linode.com/docs/websites/nginx/basic-nginx-configuration
http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/
http://httpd.apache.org/docs/1.3/urlmapping.html
Hope this helps someone!!

Resources