Answer the question
In order to leave comments, you need to log in
Is nginx configured correctly?
Is nginx configured correctly?
The site on nextjs is running on port 3000 with its own domain. The backend is written in express. And running on localhost:3001. React site admin, distributed by express from localhost:3001. I do this: I go to the site / admin, I see an empty page and css \ js were not loaded in network
nginx
project structure
server {
listen 80;
root /var/www/alexandra.proto-dev.ru;
index index.html;
server_name alexandra.proto-dev.ru;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
location /api {
client_max_body_size 100m;
proxy_pass http://127.0.0.1:3001;
}
location /admin {
proxy_pass http://127.0.0.1:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
location /nginx/ {
root /var/www/;
autoindex off;
}
location ~ /\. {
deny all;
}
}
.connect(process.env.MONGODB_URI, mongooseOptions)
.then(() => {
if (isProduction) {
mongoose.set('debug', true);
}
app.use(express.static(path.join(__dirname, 'client', 'build')));
app.use(formidableMiddleware());
app.use(require('./routes'));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client', 'build', 'index.html'));
});
routesErrorHandler(app);
app.listen(process.env.PORT || 3000, () => {
console.log(`Сервер запущен на порту ${process.env.PORT}`);
});
})
.catch(err => {
console.log(err);
});
Answer the question
In order to leave comments, you need to log in
So, nginx is configured correctly, the problem is with building the frontend. It needs to be addressed in a separate issue.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question