Responses to the discussion on Github
Collaborator
Please see this documentation relating to Nginx: strapi/nginx-proxy.md at 22c93d1040857d1a959554f49bc413c23ff075a0 · strapi/strapi · GitHub
(PR Merged already but docs have not been deployed yet)
Collaborator
As for sub-folder based proxying, it’s not currently supported but a change for that has already been purposed here: #5724
Once that PR is merged, I will be adding additional documentation for it
Author
@derrickmehaffy Thanks a lot I haven’t seen this documentation…
I’ll try right now and try to figure out what was the problem.
Author
@derrickmehaffy I try with the new configuration and i’m stiil having a 502 gateway.
Here is my config and the error_log.
I can’t find where this error comes from…
/etc/nginx/sites-available/syncly.eu
server {
# Listen HTTP
server_name syncly.eu www.syncly.eu;
# Redirect HTTP to HTTPS
return 301 https://$host$request_uri;
}
server {
error_log /home/dev/logs/error_log/error;
# Listen HTTP
listen 443 ssl; # managed by Cerbot
server_name syncly.eu www.syncly.eu;
# SSL config
ssl_certificate /etc/letsencrypt/live/syncly.eu/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/syncly.eu/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# Proxy Config
location / {
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;
}
}
/etc/nginx/conf.d/upstream.conf
upstream strapi {
server 127.0.0.1:1337;
}
[error] 11907#11907: *127 connect() failed (111: Connection refused) while connecting to upstream, client: 92.170.114.14,
[error] 11907#11907: *129 connect() failed (111: Connection refused) while connecting to upstream, client: 92.170.114.14,
[error] 18819#18819: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 92.170.114.14,
18819#18819: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 92.170.114.14,
Collaborator
502 is a gateway failure meaning Nginx can’t connect to Strapi
Author
Thanks Derrick I’ll try to find why.
did you ever find this out - i’ve been trying for a month to get this working and nothing i do works. stuck with 404 on
/admin/runtime~main.90b07e82.js
/admin/main.27aeaeba.chunk.js
i’m gonna get chunked on this project if i dont figure a solution soon
Hi, I did setup Strapi on local with Nginx for my personal project and it worked fine.
However to make it work with https through a proxy I had to declare in strapi config files the address for the proxy route like the following :
#src/config/environments/[current_mode_being_used]/server.json
{
"host": "localhost",
"port": 1337,
"proxy": {
"enabled": true,
"ssl": true,
"host": "www.mystrapi.test",
"port": 443
},
"cron": {
"enabled": false
},
"admin": {
"autoOpen": false
}
}
Could this help or you’ve been already doing it like so ?
Author
Hi @flofleche
Thanks for your help.
It was a problem between NGINX and Strapi as @derrickmehaffy said.
I delete everything and restart and it was working. I don’t know where was the bug.