I tried a lot to get the "Vue-material-dashboard Laravel" working. Here is the url to the project.
I manage to serve the thing, but when I try to login and it says: "Invalid credentials".
Looks like this:
As you can see below I also send them a ticket ;) But have not gotten help from them yet, so I decided to see if someone can help me here
Version of Vue-material-dashboard Laravel
latest
Reproduction link
Nginx file:
server {
listen 8080;
index index.php index.html index.htm;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
root /data/vue-material-dashboard-laravel/laravel-json-api/public;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
# location ~ /\.(?!well-known).* {
# deny all;
# }
}
Operating System
Ubuntu
Device
server
Browser & Version
firefox, latest
Steps to reproduce
I set all up according to documentation and run npm run build.
I let nginx server the laravel/public folder. I use a rather minimal nginx configration in sites-enabled folder (see nginx code above)
What is expected?
I use the npm command, output tells me to look at http://example.com:8081
Everything looks fine and login should be working with default given login
What is actually happening?
I get some sort of backend, but cannot login.
It says: "Invalid credentials"
Solution
Do you maybe have a nice example of how nginx should server the app?
I could not find anything online. I tried running vue-material-dashboard over https by adding "vue.config.js":
module.exports = {
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 8081, // CHANGE YOUR PORT HERE!
https: true,
hotOnly: false,
},
}
Then indeed everything goes through https but login does still not work. Any ideas why? Seems api does not communicatie well with vue
Additional comments
If we can let it all work on a linux server we woudl want to go and buy the PRO version eventually (after we tested it and so on)
Related
I have a Laravel 9 project that is hosted on AWS EC2 Ubuntu (ngnix). The domain is registered with GoDaddy and I changed the A record to point it to the IP at AWS EC2. My website runs fine when I used url like example.ca, however, it does not work when I use url www.example.ca ( I get the default Welcome to nginx! page)
As per Google Search I added the following rewrite rule in public/.htaccess
RewriteCond %{HTTP_HOST} ^www.example.ca [NC]
RewriteRule ^(.*)$ http://example.ca/$1 [L,R=301]
However, it did not help. I still continue to get the default Nginx page.
Is there anything else I need to do? For instance, in sites-enabled. I want to add that when I did setup my project, I created a new file in the /etc/nginx/sites-available folder with the following contents
server {
listen 80;
listen [::]:80;
server_name example.ca;
root /var/www/vhosts/example.ca/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Any help is highly appreciated.
Changing server_name example.ca; to server_name example.ca www.example.ca; fixed the issue. (Thanks to Andrew St-Denis.)
server {
listen 80;
listen [::]:80;
server_name example.ca www.example.ca;
I'm currently using the default configuration below, provided by Laravel here:
server {
listen 80;
server_name www.example.com;
root /srv/www/example/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
What configuration should I use instead to switch to SSL with Let's Encrypt ?
With this current configuration, when I run certbot, I'm getting the error below:
~ sudo certbot --nginx -d www.example.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for www.example.com
Waiting for verification...
Challenge failed for domain www.example.com
http-01 challenge for www.example.com
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: www.example.com
Type: unauthorized
Detail: Invalid response from
http://www.example.com/.well-known/acme-challenge/KLiVD9nJaMVqJoljNziftqSJXFXCEXsV5mf_d9WthdM
[123.123.123.3]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML
2.0//EN\">\n<html><head>\n<title>404 Not
Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
When scanning ports from outside my network, I get:
$ nmap 123.123.123.3
Starting Nmap 7.70 ( https://nmap.org ) at 2020-12-14 11:13 CET
Nmap scan report for 213.163.173.3
Host is up (0.0061s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
80/tcp open http
113/tcp closed ident
443/tcp open https
I have successfully launched 2 domains on my Laraver Forge service hosted on Digital Ocean, but I´m having a tough time launching the third.
I bought the new domain -sacbe.dev- from Google Domains, and my setups are as follows:
On Google Domains:
On Digital Ocean:
On the Forge Site:
Now, when I deploy the site on Forge, no errors are shown, and if I click on Forge´s green arrow or just go to the site: sacbe.dev, www.sacbe.dev on my desktop I get redirected to one of my other sites, also hosted on DO/Forge, but if I try the site on my iPhone I get:
"Safari cannot open the page because it could not establish a secure
connection to the server"
. So, naturally, I go back to Forge->SSL->LetsEncrypt to get a SSL Certificate, but what I get in return is:
ERROR: Challenge is invalid!
My nginx configuration:
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.sacbe.dev/before/*;
server {
listen 88;
listen [::]:88;
server_name www.sacbe.dev;
root /home/forge/www.sacbe.dev/public;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.sacbe.dev/server/*;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/www.sacbe.dev-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/www.sacbe.dev/after/*;
So I´m obviously stuck... Please help!
Thank you.
Today I tried installing the SSL Certificate again... and it worked! I guess the Nameservers propagation took much longer than expected, but it finally came through, now my site is online and all is well.
I'm running a static built nuxt.js app on my server. It uses the nuxt auth module for authentificating against my laravel backend which runs laravel passport.
My auth-strategy looks like this:
auth: {
strategies: {
'laravel.passport': {
url: 'https://correct_url',
//client_id: 1, //for local use
//client_secret: 'CLIENTSECRET1', //for local use
client_id: 2,
client_secret: 'CLIENTSECRET2',
userinfo_endpoint: 'https://correct_url/oauth/me'
}
}
},
In my local environment (yarn run dev) everything runs fine. After I built and deployed my nuxt-app (yarn run build) the authentification process comes to the authorisation step (where I can click "Authorize" or "cancel"). After I click "Authorize" browser redirects to my nuxt-app but requests still give me:
{"message":"Unauthenticated."}
After a few investigations the only possible cause for this could be the nginx-site which is automatically created through laravel forge. Config looks like this:
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/correct_url/before/*;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name correct_url;
root /home/forge/correct_url/dist;
# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/correct_url/589448/server.crt;
ssl_certificate_key /etc/nginx/ssl/correct_url/589448/server.key;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/correct_url/server/*;
location / {
try_files $uri $uri/ /index.html;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/correct_url-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/correct_url/after/*;
is there something I overlooked or am I on the wrong path?
I need your help on tuning a bit Nginx and my server.
I've got a website which is hosted on my server, and an API, also hosted on this server.
The website sends Ajax requests to the API. The problem is, once I've opened a page, which sends Ajax requests to the API, I cannot browse the website anymore using this browser because, I've reached the number of allowed connection for this browser on the website's server.
How can I change Nginx or the server configuration in order to increase the number of connections allowed per browser?
Thanks for your help.
EDIT
Server conf
worker_processes 4;
worker_connections 1024;
multi_accept on;
keepalive_timeout 65;
Server block
server {
listen 80;
server_name mywebsite.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
ssl on;
ssl_certificate /path/to/pem;
ssl_certificate_key /path/to/key;
# Set the server name
server_name mywebsite.com;
# add Strict-Transport-Security to prevent man in the middle attacks
add_header Strict-Transport-Security "max-age=31536000";
root /path/to/root/folder;
index index.php;
# Logs
error_log /path/to/error.log;
access_log /path/to/access.log;
# strip app_test.php/ prefix if it is present
rewrite ^/index\.php/?(.*)$ /$1 permanent;
location / {
index index.php;
try_files $uri #rewriteapp;
}
location #rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(index)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_read_timeout 43200;
internal;
}
# Define error pages
# Error pages are located in the app folder
error_page 403 403.html;
location = 403.html {
root /path/to/error-pages;
internal;
}
error_page 404 404.html;
location = 404.html {
root /path/to/error-pages;
internal;
}
error_page 500 502 503 504 50x.html;
location = 50x.html {
root /path/to/error-pages;
internal;
}
}