I have instaled node.js and npm on EC2 through command line and also uploaded all my files for Strongloop project
When I'm running the server locally it is working fine but when I'm running the node server.js on EC2 command line. it is running but saying:
Web server listening at: http://0.0.0.0:3001/
ENVIRONMENT : development
How could I start my server on AWS EC2... Can't figure it out.
My Config.json file
{
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3001,
"remoting": {
"context": {
"enableHttpContext": false
},
"rest": {
"normalizeHttpPath": false,
"xml": false
},
"json": {
"strict": false,
"limit": "100kb"
},
"urlencoded": {
"extended": true,
"limit": "100kb"
},
"cors": false,
"errorHandler": {
"disableStackTrace": true
}
},
"legacyExplorer": false
}
Few possible things:
Make sure the port you are using is in your AWS Security Inbound Rules. Go to 'Security Groups', then select the group associated with your instance then click "Inbound". In your case, you have to add the port 3001 for HTTP protocol and the source 0.0.0.0/0.
You need to keep the service running even after you close the terminal/command-prompt window. To make the server start automatically and run in the background, you need to use something like 'systemctl' in ubuntu. Here is a step by step guide and tutorial: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
Now try visiting your IPv4 Public IP or your associated domain name with the port number. e.g. 1.2.3.4:3001 or mywebsite.com:3001. The IP is written in the same row as your instance in AWS.
Related
I installed the json-server from https://github.com/typicode/json-server and works fine, I can execute GET, POST etc., but locally only. When I try to connect from the outside it doesn't work.
I tried to turn off firewall, change ports and diffrent startup settings (i.e json-server --host 192.168.0.21 db.json) and nothing helped. Here's my database.
[
{
"id": 2,
"login": "admin3",
"haslo": "haslo3"
},
{
"id": 3,
"login": "admin2",
"haslo": "haslo2"
},
{
"login": "admin1",
"haslo": "haslo1",
"id": 7
}
]
I would like to be able to connect to my server from the whole world, but only local adresses work (i.e http://192.168.0.21:3000/user or http://localhost:3000/user). What's wrong with my approach?
Make sure you are starting the server bound to your adapter (ex. --host 0.0.0.0).
Then you need to setup port forwarding on your router.
https://deaddesk.top/exposing-local-server-to-the-public-internet/
I guess it's a very basic question, but it still confuses me. At development stage, when launching react with 'npm start' I'm using port 3000. In addition when launching strapi (which is a backend cms), it automatically uses port 1337.
Does it actually mean that my app is using two different ports?
I'm asking this because I would like to configure nginx so that I can run two different strapi apps (attached to two different react apps) - on the same server.
I want nginx to redirect from a specific location to the second website. I could write inside the sites-available file:
server {
listen 80;
location / {
proxy_pass "http://mysite:3000";
}
location /mysecondsite {
rewrite ^/mysecondsite(.*) $1 break;
proxy pass "http://mysite:??????? WHAT SHOULD I WRITE HERE?"
}
}
But where should I redirect users entering the secondsite url, to what port?
In strapi documentation, they point to a file called server.json where you can change the port that strapi uses, and also create a proxy (which I don't understand why you would want to do if you can just redirect from nginx?), for example:
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": true,
"ssl": true,
"host": "example.com",
"port": 8443
},
"autoReload": {
"enabled": true
},
"cron": {
"enabled": true
}
}
But changing the port of the second project will affect only the strapi backend, won't it?
How can I create a different port for the front end of the second project?
I'm sorry if I misunderstand the terms here
Thanks in advance
Update 2019-06-29: (one application - frontend & strapi)
I come back because I discover that somebody resolve your case and deploy one application with strapi.
How to integrate Strapi API and Admin Panel with another node app (that consumes Strapi API)?
So you will have to build you website app. And push the build in the ./public folder of the Strapi application.
Then in your api/.../config/routes.json files you will have to add an option prefix in the config key of each of your routes and for all your APIs
{
"routes": [
{
"method": "POST",
"path": "/restaurants",
"handler": "Restaurant.create",
"config": {
"policies": [],
"prefix": "/api"
}
}
]
}
So at the end you will have your admin on /admin
Your APIs endpoints prefixed by /api
And your website/assets on /
And you don't must configure nginx for your second application becaouse is only one.
2019-06-11: (two separate application)
You want to has main react application on port 3000 and cms for backend api on 1337 where be used by main react application? You can use configuration like in bellow.
nginx.conf
server {
listen 80;
server_name mywebsite.pl www.mywebsite.pl;
location / {
proxy_pass http://mysite:3000/;
}
location /admin/
{
proxy_pass http://mysite:1337/admin/;
}
location /strapi/
{
proxy_pass http://mysite:1337/;
}
}
server.json
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": false
},
"autoReload": {
"enabled": true
},
"cron": {
"enabled": false
},
"admin": {
"path": "/admin",
"build": {
"host": "/admin",
"backend": "http://mywebsite/strapi",
"plugins": {
"source": "backend",
"folder": "/strapi"
}
}
}
}
Remember:
⚠️ If you changed the path to access to the administration, the step #2 is required
-> You must resetup admin to install the dependencies and build the project
Change on the production environment NODE_ENV flag to production.
Run the server with the production settings.
Resource:
Deploy the administration panel on another server then API
Deployment
Hello guys im Running an vagrant machine with localhost:8088
my gulp task starting the an default local host on : http://localhost:3000/ how is it possible to reload my vagrant localhost:8088 if changes appears (Just the Browser should i use live-reload?
)
gulp.task('browserSync', function () {
browserSync.init({
proxy: '127.0.0.1:3005',
target: "localhost:8088",
open: true,
notify: true
})
});
tryed this but still without success
Try to mention open parameter as external and give the port and address in parameters as below
{ "host": "localhost", "open": "external", "port": 8088 }
Hope this works
I'm unable to use Visual Studio Code to debug my node application.
My .vscode/launch.json looks like this:
{
"version": "0.2.0",
"configurations": [{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 9001
}]
}
I use grunt-contrib-connect to start my web server. My connect task is defined my my gruntfile.js like this:
connect: {
server: {
options: {
debug:true,
port: 9001,
base: '.',
livereload: true,
},
},
},
After successfully starting the web server with the above task, I try to attach from VSCode, but apart from some UI flashes, nothing seems to happen. No breakpoints are hit.
I read the VS Code Debugging Documentation, especially the Attaching VS Code to Node section, which is why I added the debug:true to my connect task. However this did not seem to fix anything.
If I understand the "port" in grunt-contrib.connect correctly, then this is the port on which the webserver will respond, not the debugging port.
So in your .vscode/launch.json you must specify the debug port not the webserver port. Since grunt uses node, I assume the debug port is node's default port 5858.
I am new to logstash. I installed elasticsearch, kibana, logstash and logstash-forwarder in Ubuntu from this tutorial everything is fine while running on the local machine.
Now I want to include log file from another system so I installed logstash-forwarder on client machine but it fails to run. I cannot able to figure out mistake. In client machine I didn`t install logstash since logstash is running on server.If anything I misunderstood please let me know. What would be the configuration of server and client access.
Logstash forwarder in client:
{
"network": {
"servers": [ "server_ip_addr:5000" ],
"timeout": 15,
"ssl ca": "/etc/pki/tls/certs/logstash-forwarder.crt"
},
"files": [
{
"paths": [
"/var/log/syslog",
"/var/log/auth.log"
],
"fields": { "type": "syslog" }
}
]
}
Thanks
Install logstash-forwarder is enough.
Here are the ways to troubleshooting your problem.
Check if logstash is running on port 5000
Login logstash server, and run :
telnet localhost 5000
If you can't telnet, then make sure, logstash service is running properly.
Check if there are firewall issue between clients and logstash server.
Login client (where you installed forwarder on it)
telnet server_ip_addr 5000
If you can't, you need open the firewall port 5000 between client to logstash server.
In config file, the file part is fine, could you update the network part,
Let me know the result
"network": {
"servers": [ "server_ip_addr:5000" ],
"timeout": 15,
"ssl certificate": "/etc/pki/tls/certs/logstash-forwarder.crt",
"ssl key": "/etc/pki/tls/certs/logstash-forwarder.key",
"ssl ca": "/etc/pki/tls/certs/logstash-forwarder.crt"
},