Hello
I’m trying to set up the Microsoft Auth Provider for my Strapi staging server hosted on an Azure VM.
I’ve been able set up to the domain name as well as SSL using Nginx as per the Sub-Folder-Split configuration described here: https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/deployment/optional-software/nginx-proxy
I am able to access both the Strapi admin as well as the api without any issues.
However, when I try to login from my frontend application using Strapi’s Microsoft Auth provider, I get a “502 Bad Gateway” error from Nginx. This happens after I correctly enter my Microsoft Login credentials and it redirects me to myserver.com/api/connect/microsoft/callback?code=
I was able to login successfully using Microsoft Auth when testing using ngrok tunnels prior to setting up nginx.
Could you point me to documentation that could help resolve this? Sorry I was not able to find around using auth providers along with nginx.
Here is my nginx config:
/etc/nginx/conf.d/upstream.conf
# Strapi server
upstream strapi {
server 127.0.0.1:1337;
}
/etc/nginx/sites-available/strapi.conf
server {
# Listen HTTP
listen 80;
server_name myserver.cloudapp.azure.com;
# Redirect HTTP to HTTPS
return 301 https://$host$request_uri;
}
server {
# Listen HTTPS
listen 443 ssl;
server_name myserver.cloudapp.azure.com;
# SSL config
ssl_certificate /etc/letsencrypt/live/myserver.cloudapp.azure.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myserver.cloudapp.azure.com/privkey.pem;
# Static Root
location / {
root /var/www/html;
}
# Strapi API
location /api/ {
rewrite ^/api/?(.*)$ /$1 break;
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
# Strapi Admin
location /strapi-admin {
proxy_pass http://strapi/strapi-admin;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
}
System Information
- Strapi Version: v3.5.4
- Operating System: Ubuntu 18.04
- Database: Postgres
- Node Version: v3.5.4
- NPM Version: v3.5.4
- Yarn Version: 1.22.10