Responses to the discussion on Github
Collaborator
Did you create the upstream.conf file specified here: Strapi’s documentation | Strapi Documentation
Also what OS are you using as certain versions of linux don’t, by default, load the /etc/nginx/conf.d
directory (CentOS, Debian, and RHEL come to mind. However Ubuntu does)
Author
Hi @derrickmehaffy
Thanks for your support!
I’m using Ubuntu 18,04 LTS.
And yes, I think that I have all the files required:
/etc/nginx/conf.d/upstream.conf
upstream strapi {
server 127.0.0.1:1337;
}
/etc/nginx/sites-available/strapi.conf (Subfolder unified config)
server {
# Listen HTTP
listen 80;
server_name _;
# Redirect HTTP to HTTPS
return 301 https://$host$request_uri;
}
server {
# Listen HTTP
listen 443 ssl;
server_name _;
# SSL config
ssl_certificate /etc/ssl/certs/iRedMail.crt;
ssl_certificate_key /etc/ssl/private/iRedMail.key;
# Static Root
location / {
root /var/www/html;
}
# Strapi API and Admin
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;
}
}
After writed /etc/nginx/sites-available/strapi.conf I made a symlink to /etc/nginx/sites-enebled:
ln -s /etc/nginx/sites-available/strapi.conf /etc/nginx/sites-enabled/
And I didn’t forgot /config/server.js
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'https://botboutique.com.br/api',
});
Strange, no?
Collaborator
Can you run a service nginx configtest
then tail the nginx error log tail /var/log/nginx/error.log
. That should dump out the exact problem with the config and why it’s failing.
Author
Morning, @derrickmehaffy !
here is the log:
2020/07/10 06:32:57 [error] 119003#119003: *17056 “/var/www/html/webfig/index.php” is not found (2: No such file or directory), client: 128.14.209.234, server: _, request: “GET /webfig/ HTTP/1.1”, host: “191.252.196.107”, referrer: “http://191.252.196.107/webfig/”
2020/07/10 08:55:58 [error] 119003#119003: *19981 “/var/www/html/webfig/index.php” is not found (2: No such file or directory), client: 128.14.209.178, server: _, request: “GET /webfig/ HTTP/1.1”, host: “191.252.196.107”
2020/07/10 10:20:53 [error] 119003#119003: *21722 open() “/var/www/html/owa/auth/logon.aspx” failed (2: No such file or directory), client: 192.241.238.240, server: _, request: “GET /owa/auth/logon.aspx?url=https%3a%2f%2f1%2fecp%2f HTTP/1.1”, host: “191.252.196.107”
2020/07/10 11:26:02 [emerg] 20890#20890: host not found in upstream “strapi” in /etc/nginx/sites-enabled/strapi.conf:27
2020/07/10 12:25:44 [emerg] 28830#28830: host not found in upstream “strapi” in /etc/nginx/sites-enabled/strapi.conf:27
2020/07/10 12:26:04 [emerg] 28933#28933: host not found in upstream “strapi” in /etc/nginx/sites-enabled/strapi.conf:27
It seems that the host in upstream wasn’t found.
But /etc/nginx/conf.d/upstream.conf exists and I tried variuos combinations:
upstream strapi {
server 127.0.0.1:1337;
}
upstream strapi {
server localhost:1337;
}
upstream strapi {
server botboutique.com.br:1337;
}
Seems that the server pointed in upstream.conf isn’t been recognized.
Collaborator
Indeed it seems it’s being ignored, in your /etc/nginx/nginx.conf
there should be a line in the http { }
block that looks like include /etc/nginx/conf.d/*.conf;
(It should be above the line include /etc/nginx/sites-enabled/*;
)
Collaborator
Looking at a freshly installed nginx on ubuntu server 20.04 the bottom half of my nginx.conf
looks like this:
...
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
[
LuizCesarLeite](LuizCesarLeite (Luiz Cesar Leite) · GitHub)146d ago
Author
Hi @derrickmehaffy !
Putting include /etc/nginx/conf.d/*.conf
in nginx worked like a charm, thank you.
But despite there’s no error message about nginx and npm start , I can’t access the admin area ![:frowning: :frowning:](https://forum.strapi.io/images/emoji/twitter/frowning.png?v=12)
Author
I edited the previous message, because I can’t get access to admin, even with no erroes in npm start my-project
. When I tried to access “botboutique.com.br:1337/admin” or “botboutique.com.br:1337/api/admin” shows me an SSL error SSL_ERROR_RX_RECORD_TOO_LONG
.
![image](https://d38xoolefqxt5u.cloudfront.net/original/2X/3/3feb19ea171f0b89f8257daae7aaa74e75ebed9b.png)
Collaborator
You shouldn’t be trying to access it on :1337, based on what your Strapi console is showing you would access it without the port.
Collaborator
@LuizCesarLeite did you still need help with this?
Author
Sorry my lack of attention and detail: I have a ./config/server.js file with
module.exports = ({ env }) =>({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: 'https://botboutique.com.br/api',
})
So, when try to access by this URL (or https://botboutique.com.br/api/admin), I get a 404 message ![:frowning: :frowning:](https://forum.strapi.io/images/emoji/twitter/frowning.png?v=12)