can i get ip address for free account on heroku - heroku

I want to deploy chat app made in socket.io on heroku's FREE ACCOUNT
It works fine with local ip - 127.0.0.1.
It works fine with Static Ip - ......
but now i want to deploy app on FREE ACCOUNT made on heroku
heroku gave me
url : https://pure-savannah-3208.herokuapp.com/
And in Socket.io i want to put ip address here
var socket = io.connect('http://192.168.0.102');/*How will i get ip address*/
$('form').submit(function(){
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
});
Does heroku provides ip address for free account
or
is there any other way to use this scenario.?

Socket.io accepts domain names, not just IP addresses.
You don't need to do anything.

Related

How can I add an email adapter to my amazon EC2 instance to enable password resets for my app

The steps that I have already done are as follows:
1)I've set up my EC2 instance already.
2) I've linked it up to amazon CodeDeploy
3) I've created an s3 bucket that will hold my cloud code when I push it to my instance.
4) I've created a folder that will contain my cloud code.
5) I've initialised npm within it and created an index.js file (it is a sublime text file actually - not sure if this is correct or not?)
6) I've set things up from the command line that index.js is the main entry point.
7) I have put the following email adapter code within it:
var server = ParseServer({
// Enable email verification
verifyUserEmails: true,
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
// Set the mount path as it is in serverURL
publicServerURL: 'etc',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'etc',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
});
8) I've set up an account with mailgun its asking me for a domain to send the emails from? I'm not sure what this is?
My main question is regarding the code i posted above. Is this enough to put into index.js to create an email adapter? And is uploading a sublime text file ok? How can the cloud know what "ParseServer" class is without importing libraries? - Do i have to add anymore code to index.js?
Additionally what else do I need in the cloud code package besides the index.js file? This has been such an obscure topic and there seems to be no clear guides online as to how to upload functional cloud code to amazon EC2 instances.
Any help appreciated, cheers.
Part of your steps are correct but you must also modify the form and the domain. Your domain (to your question) must be taken from your mailgun account. You must add some steps in order to setup your domain with your DNS provider (e.g. goDaddy etc.) If you don't want to use you can try to use the default sandbox domain that has been provided to you by mail-gun but it's better to use your own domain. In the from field you need to put some email address so users that will receive the email will see from which email this message sent to them. usually what I love to put is donotreplay# ( is your domain of course)
In my project, this is how I configure it (and it works):
"verifyUserEmails": true,
"emailAdapter": {
"module": "parse-server-simple-mailgun-adapter",
"options": {
"fromAddress": "donotreply#*******.com",
"domain": "mail.*******.com",
"apiKey": "<API_KEY_TAKEN_FROM_MAILGUN>"
}
},
Your list of domain in mail-gun can be found in here: https://app.mailgun.com/app/domains (login is required of course)
in here: https://documentation.mailgun.com/en/latest/user_manual.html#verifying-your-domain you can read how to verify your domain
Hope it helps.

Cannot send email from parse-server on heroku

i am running my migrated app on Heroku Parse-Server. When i try to send a password reset email from my app using 'requestPasswordResetInBackground' i get the following error:
"An appName, publicServerURL, and emailAdapter are required for password reset functionality.".
It used to work fine on Parse.com.
I’ve read about initiatives for implementing this missing functionality. Does anybody know if such an implementation is already available or will be soon, and if so how to configure it?
Thanks!
You need to go to mailgun.com and register an account. Then create a new domain in mailgun. You will get an api key for this domain.
Then you need to read through the readme for parse migration
https://github.com/ParsePlatform/parse-server/blob/master/README.md. There is example for mailgun. It is in the Parse Server so you don't need to install any extra template or require something at the index.js.
Add the following code in your index.js. It should be after your server initialization
var server = ParseServer({
//... your other configurations
// here the configuration for email begins
verifyUserEmails: true, //depends on your needs, you can set it to false
emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds)
preventLoginWithUnverifiedEmail: false, // defaults to false
publicServerURL: 'https://example.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
After you change the updated index.js in your Parse server, you will be able to get email from mailgun. It could take some minutes to get the email.
Then you also need to implement the email resetting html pages on your own server. I haven't found a good tutorial yet.
If you installed the Parse server directly by Heroku, you will have server.js instead of index.js, you can find it in this directory: /opt/bitnami/apps/parse/htdocs/ and do all the changes in this file and restart the server

expose application to IP range or validate a login requet against an IP range

Is there a Wakanda way to:
expose a Wakanda application only to a specific IP address or IP range
validate a login request (custom login) against an IP address or IP range
I will answer the questions one by one :
1-
This should be done using your OS' firewall (using iptables for instance if you are on Linux)
2-
If you restrict access to the app using the firewall, you might not need to do this. But if you really need to :
Today there is no good way to do this, because you can't disable the authentication REST API. The workaround I propose is as follows (but I don't think it will work if you are using active directory ):
Add a custom request handler for authentication /login where you do something like :
function login(request,response){
var ip = request.remoteAddress;
if( ! isIPAuthorized(ip)){
response.statusCode = 403;
return;
}
sessionStorage["login-request"] = true;
/*
* Your login code here
* For instance you can use loginByPassword, createUserSession ..
*/
sessionStorage["login-request"] = false;
}
Inside your Login Listener you can check if the login request came from you custom login function or not by checking the sessionStorage :
if(!sessionStorage["login-request"]){
return {
"error" : 1024,
"errorMessage" : "Unautorized Login Attempt"
}
}
This way any login attempt using the default REST authentication API where IPs are not checked will be refused.
The best way to expose any application to a specific range of IP addresses (while blocking all others) is with a firewall; whether it be a software-based firewall (such as iptables or windows-firewall) or a hardware-based firewall (such as a Cisco ASA). Using a firewall completely alleviates the need for the second part of your question.
For the first question, enable the Cross-origin resource sharing in the Project Settings file ( Settings.waSettings ), and you need to define the list of Domain name or IP address from where external pages are allowed to send data requests to the Wakanda Server via CORS. Multiple domain attributes can be added to create a white list.

Youtube data API refusing my server side requests

I'm developing an application that uses the Youtube Data API from the server (with node.js) so I have my server side credential key already set up but when I try to get data is always refusing my requests with this message.
Access Not Configured. The API is not enabled for your project, or there is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your configuration.
I've my app hosted in Heroku with the add-on Quote Guard Static that gives me two static IP's that I have whitelisted in the Credentials section of the google developers console. I also have the app hosted in modulus.io and whitelisted the IP range 54.0.0.0/8 that is what they gave me for their AWS region... Any of both deployments are working only in my local machine with my home external IP whitelisted.
The funny thing is that yesterday 15 minutes approximately after I whitelisted the 54.0.0.0/8 range, the app API started working in my Heroku host, but today it stopped again (this might be because it has changed to another IP inside their AWS region or something...).
Is there any way to check what IP is doing the requests to the Youtube data api? I can see in the developers console the request reaching the API and been rejected as "errors" at least I know that their are getting the requests...
Any ideas??
Thanks
EDIT:
Partially solved. See my answer below.
There's a simple service I found that returns your public IP:
http://api.ipify.org?format=json
You could add a route to your application that you can hit from your browser. The route handler then makes a request to this service and returns the result. You could then periodically check what your app's actual public IP is and adjust whitelist accordingly.
// Example express + request
app.get('/ip', function(req, res) {
request({ uri: 'http://api.ipify.org?format=json' }, function(err, response, body) {
res.send(body);
});
});
The problem with the app hosted in Modulus.io is solved now. The app was running by default in Joyent servers but I changed it to the Amazon AWS region and with the IP range 54.0.0.0/8 whitelisted google is accepting all my requests to the API.
Nevertheless, the app in heroku still not working but as is working in one service I'm going to stop investigating in the other one.

Codeigniter email function and Justhost SMTP

I had somebody build me a site using PHP and Codeigniter framework.On the test server everything was working properly, but now, once the site is transfered on Justhost, email function doesnt work.At first i tought i didnt used the correct SMTP settings, but they are fine (support took a look).
Basically, owner can put his property on the site (like this:http://goo.gl/AZcrj), and when the visitor fills the contact form on the bottom, email is sent to owners email address, and the he can reply to the visitors email.
First time i used Justhost SMTP settings and tested it, email was sent.But from that point, till now, i always get an error when i try to send message via contact form.I even tried using Gmail SMTP settings, same thing happens :\
Here is the code, does anybody have any clue?
Btw, im a PHP rookie, so i dont know much, but i did my best to explain
public function send_mail($res)
{
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'sslsmtp.gmail.com'; --- i tried with ssl://smtp.gmail.com, same thing happens
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user'] = 'email';
$config['smtp_pass'] = 'password';
$this->email->initialize($config);
$this->email->from($res['sender_email'], $res['sender_name']);
$this->email->to($res['reciever']);
$this->email->reply_to($res['sender_email'], $res['sender_name']);
$this->email->subject('Email from site.');
$this->email->message($res['message']);
if($this->email->send()) {
return true;
} else {
return false;
}
//configure mail agent...
}
It seems Justhost blocks outgoing ports for shared IPs. I was having the same issue and came across this link (https://my.justhost.com/cgi/help/405) while searching for an answer.
From the above link:
Outgoing Ports Are Blocked
Just Host restricts port access as a result of the shared hosting
environment. In this environment, every account on a server shares a
single IP address. As a result, most ports are blocked because no
single account is assigned the IP address for the box.
To gain access to these ports, it is necessary to lease a dedicated IP
address through Just Host.

Resources