Directus on remote server - node.js

I have an app on remote server. I use directus of this app and I have a site example.com. I want to make able the route example.com/admin manage content . I try to start directus with command pm2 start npm --start, but I get this enter image description here
Can you help me?

You would be better off serving Directus on a subdomain (admin.example.com), this will separate the back-end from the front-end. The root URL for the Directus install is the API URL, followed by /admin for the editing interface.
If you have installed Directus under /admin then the API will likely be available at example.com/admin and I believe the interface will be under example.com/admin/admin, which is why I suggest a subdomain.
I generally use mgmt.example, cms.example or similar variations.

Related

NodeJS redirect to internal localhost server

I am new to nodejs so apologies if this is a bad question.
I am using NodeJS + Auth0 to authenticate a shiny webapp. I have most of it working now including the call back but am stuck on the last step.
Assuming it authenticates, I want to proxy pass directly to 127.0.0.1:3838/myapp.
In other words, if the loopback address were public I could do:
res.redirect('http://127.0.0.1:3838/myapp/');
However, as it's not public that is no longer an option. Any advice?
res.redirect('/myapp'):
Should redirect you to the /myapp route assuming that you are running the NodeJS app locally on 127.0.0.1:3838
Have a look at https://stackoverflow.com/a/44445540/16471349

Is it possible to host Wordpress Blog under route of React App

Is that possible to host a Wordpress Blog under a route in my React Web App?
For example, my React App is running on domain www.myreactapp.com, can I host a Wordpress blog under route www.myreactapp.com/blog.
When I worked with PHP Web APP, it was easy, you just need to create sub-folder named "blog" and install Wordpress in it. I am hoping to get a solution like in PHP Apps, if yes I can just make use of all features of Wordpress with less amount of coding.
Thanks in advance
You cannot do it directly as WordPress have its own configuration which is necessary for WordPress website due to which admin panel will not work, but you can use WordPress API to load the data you wanted from WordPress and show in react app.
I am not sure this is exactly what you wanted or not but you can also setup the WordPress separately in sub domain like http://blog.myreactapp.com
Also let me know if you found any working solution
All,
We can host the Wordpress blog along with React App like in the question(for example www.myreactapp.com/blog).
Steps
Use Nginx to host the React App
Install Wordpress
Add a rule in Nginx to proxy the request to WordPress when the request comes to /blog. http://nginx.org/en/docs/http/ngx_http_proxy_module.html
Hope this helps
Thank you

How to host node code in virtual directory

I have 2 separate code of node application. I have already deployed node code on a windows server. Code runs on port 80 so when I hit my domain like www.myproject.com it loads my home page of my node server.
When I hit www.myproject.com/admin it should give me the admin page form my other node js code.
You are a bit short on information in your question, but I'll do my best with what you've given. Assuming you have 2 instances of node on your machine, but want a user to only access one, and you are using express, I would suggest an http proxy on one to route to the other such as:
https://www.npmjs.com/package/express-http-proxy
Setup your /admin route to access your uri of your 2nd instance. Hope that helps.

Messenger bot - Sample code

I am trying to create a bot. Using this project. My setup is as follows:
Amazon EC2 instance. I created a sub-domain.domain.com I have added the ssl certifications. I have pointed the sub-domain to the /var/www/sub-domain/
I have installed the unzip and installed the project in /var/www/sub-domain/project/ I have configured the project and correctly run it:
Node app is running on port 5000
If I access http://sub-domain.domain.com:5000 I access to the projects public index. I understand that means the port is open and the node app works.
Now when I am trying to configure in facebook my webhook I dont understand what url callbak to use. From what I understand in the configuration the server url whould be https://sub-domain.domain.com and the configuration should work. but it doesnt.
What url should I use?
Your callback URL should be your actual file where facebook would send user data. Like if you were using PHP, you'd say: http://yourhost/chatbot.php. Currently, webhook would be the URL on which your node app is listening.
Your webhook needs to an accessible URL. I don't know which sample code you used, but my guess is that with your current set up you should use http://sub-domain.domain.com:5000/webhook.
You can use Apache or Nginx to make it accessible on http://sub-domain.domain.com/webhook (port 80) with ProxyPass/proxy_pass directives.
I have installed the unzip and installed the project in /var/www/sub-domain/project/ [...] I access to the projects public index
The Javascript files of your project don't need to and should not be accessible to the public, as they may contain your application's secret IDs and tokens.

Integrating node.js and express website with wordpress hosting

I have a website running on node.js and express, hosted on Amazon EC2 with a normal domain (e.g. www.example.com)
We want to add a blog to the website. We would like the blog route to be www.example.com/blog
I have tried a Ghost installation under node.js (with a proxy layer to handle the port and url remap). I got it working ok, but the feature set is not robust enough for our content creators. They would rather work with WordPress.
But WordPress does not have a node.js install, and I do not have the bandwidth to set up and run a WAMP server in addition to the node.js server we currently use.
So I am investigating using a another hosting option for wordpress and using a proxy layer to redirect to the hosted wordpress blog.
From what I have read online, WordPress hosting will not work (cannot configure the URL properly on the WordPress side). And I could not get the proxy layer to work with a test account.
Will a 3rd party (like GoDaddy) work?
I am envisioning that we host the blog on GoDaddy. And on our site, I set up a proxy to map www.coursehunter.org/blog to the GoDaddy hosted Wordpress blog. Has anyone done this? Does it work technically? I understand I would probably have to edit the .htaccess file.
Are there SEO gotchyas from an implementation perspective? The main point of our blog is to build out content for our main domain which is why we want the www.example.com/blog url.
Thanks!
I would suggest you look into Nginx web server. You can set it up as a reverse proxy for your NodeJS/Express web application and install its php-fpm module to handle the PHP part(Wordpress).
Here is a guide to set up Wordpress with Nginx https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04
And here is one with set up your NodeJS application with Nginx https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04
In your case, you will need to setup the url configuration so that the parts get routed to the correct destination that is NodeJS part is handled by reverse proxy and Wordpress is handled by php-fpm

Resources