How to setup subdomain on the nuxt js with pm2? - server

I got problem when setup subdomain on the server with nuxt js.
I have setup /etc/hosts and put 127.0.0.1 subdomain.localhost then restart the nginx server and restart the pm2. And the main domain not using localhost:3000, so port is available. But I still got an error.
Error says: Server error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
how can I solve this? Anyone can help?

pm2 has nothing to do with domain or subdomain.
As I understand, you want to proxy your nuxt app to a subdomain.
You have to launch your nuxt app with pm2:
pm2 start 'nuxt start'
and proxy localhost:3000 to your domain or subdomain like so:
server {
listen 80;
server_name subdomain.localhost;
location / {
proxy_set_header Host $http_host;
proxy_pass http://localhost:3000;
}
}

I had Plesk installed and using Plesk I have setup subdomain and put nuxt app there, seem to work. There are many ways Plesk is one way. To start app I used https://nuxtjs.org/faq/deployment-pm2/

Related

How to send fetch request from HTTPS to a HTTP server : Mixed Content error

I am using a NextJs app where I am using a simple fetch to send some POST data.
We I used app on localhost it worked fine but when I put it on the server it got following error.
Mixed Content: The page at 'https://speechwithai.com/home' was loaded
over HTTPS, but requested an insecure resource
'http://18.224.190.161:5000/fileToText'. This request has been
blocked; the content must be served over HTTPS.
The from and to are both on same IP address (https://speechwithai.com/). At the back I am running NGINX to server WebAPP at port 80 and Flask REST API at 5000. I am using Flask because I needed python libraries to process some files.
I tried multiple post but I did not find any solution. Could someone please help me?
All I want is to send a request to my FLASK API server which is running
http://someIPAddress:5000 from https://myLiveNextJsApplication.com
Since both servers are running behind same server and you already have nginx setup.
follow these steps
setup reverse proxy for flask
with some thing like below
events {}
http {
server {
listen 443;
location /flask_api {
proxy_pass http://127.0.0.1:5000/;
}
nginx configuration resides in /etc/nginx/nginx.conf
.
For more information visit https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
configure ui to use this flask_api
url = https://speechwithai.com/flask_api
update flask path route to use /flask_api

Unauthorized Session, not found, is the BigBlueButton frontend is server from localhost

the following architecture is working Working Use Case:
FrontEnd: React (web.example.com)
Server: Node.js (server.example.com)
BBB Server (bbb.example.com)
Note: The BBB is loaded in an iframe in frontend/react/web.example.com
Eg.
URL_TO_JOIN = is the url received from BBB after a meeeting is created via an API call
<iframe
allow="microphone; camera"
src={URL_TO_JOIN}
allowfullscreen={true}
>
</iframe>
Not Working Use Case:
if the FrontEnd is served in local environment React (web.example.local)
https is also setup
/etc/host
127.0.0.1 web.example.local
nginx serve the frontend/react/web.example.local traffic with https
Error message:
Unauthorized Session
not found
The following worked for me:
I've created a subdomain web.local.example.com and hosted the frontend/react/web.localhost.example.com using Nginx as load balancer with ssl
Note:
web.local.example solves the requirement of same-origin, hence resolves the issue

Redirection with nginx

Using this tutorial
http://rainbow-six3.com/plesknginx/ i am trying to redirect my name.com to ip:8080 , after that setup if i acces through name.con i get an redirection loop... is there any other service to redirect? Had a lot of problems with nginx.
I want to redirect name.com to an tomcat7 application wich uses ip:8080 to get executed. Tomcat is already an headache...
Neither this helped me:
Tomcat base URL redirection
It outputs webpage not available on link: http://name.com/index.jsp
Mind the words. 'Redirecting' != 'Proying'. You redirect through 301 or 302 to a publicly directly accessible resource, while you proxy to a backend, not supposed to be directly accessed.
The minimal configuration to proxy any name.com/<whatever> request to <ip>:8080/<whatever> is:
server {
listen 80;
server_name name.com;
location / {
proxy_pass $scheme://<ip>:8080;
}
}

Meteor ROOT_URL setting to make accounts-facebook work when behind apache proxy

I'm running meteor on localhost:3000 and I have apache set up to proxy requests for a domain to that meteor instance using a virtualhost and mod_proxy.
I'm getting this error when trying to log in to my meteor app using accounts-facebook:
Given URL is not allowed by the Application configuration.: One or
more of the given URLs is not allowed by the App's settings. It must
match the Website URL or Canvas URL, or the domain must be a subdomain
of one of the App's domains.
I think this is because my ROOT_URL is http://localhost:3000 . If I change the ROOT_URL to the domain, then of course meteor tries to listen to the domain, but can't because my apache server is in the way.
Is there a way I can make this work without another IP address?
From Meteor documentation,
Ensure that your $ROOT_URL matches the authorized domain and callback
URL that you configure with the external service (for instance, if you
are running Meteor behind a proxy server, $ROOT_URL should be the
externally-accessible URL, not the URL inside your proxy).
In my case, my app is listening on a configured port with mod_proxy behind an Apache proxy server, say it is listening http://www.example.com:8080. I have other applications running on other ports.
To get going, on Facebook I set Site URL and Valid OAuth redirect URIs to http://www.example.com:3000 and App Domains to www.example.com. On my machine I set ROOT_URL to http://www.example.com:3000, which is externally-accessible.
Such configurations work for me without a second IP address.
I could get it working by simply having
# /etc/hosts
127.0.0.1 localhost.localdomain localhost
And the facebook settings as in the image below. I've set a secondary (mobile) url to point to http://localhost:3000
I've created a whole facebook app like this, with login, access to graph-api etc. And everything was working both online and in the dev envrionment

Facebook login button disabled on localhost

I'm testing the sample Run with Friends Google App Engine Facebook app. When running on localhost:8888, clicking the login button brings up a new small window, which disappears almost instantly, and doesn't actually log in. How can I test logging into Facebook on localhost? I saw this question, but the accepted answer doesn't seem applicable to Google App Engine.
I'm using a local Nginx instance in front of dev server. Nginx really easy to configure for proxying reguest from domain like mylocalapp.dev to your app.
Configuration looks like:
server {
listen [::]:80; #it's for ipv6
#listen 80; #for ipv4
server_name mylocalapp.dev;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
And also, don't use suffix like .local for domain, it doesn't work for FB too.