server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
root /var/www/example.com/;
index index.html;
}
location /server/ {
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;
}
app.post('/var/www/example.com/server/'
советую почитать доку, посмотреть примеры.upstream serve {
server 0.0.0.0:8081;
keepalive 15;
}
server {
listen 80;
listen [::]:80;
# Add index.php to the list if you are using PHP
access_log /var/log/nginx/mushroomer.access.log;
error_log /var/log/nginx/mushroomer.error.log;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://serve;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
upstream client-upstream {
server 0.0.0.0:3000;
keepalive 15;
}
upstream back-upstream {
server 0.0.0.0:8000;
keepalive 15;
}
server {
listen ${HOST_IP}80;
server_name ${PROJECT_NAME} www.${PROJECT_NAME};
server_tokens off;
root /var/www/prod/public;
index index.php index.html index.htm;
location / {
proxy_pass http://client-upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_upgrade;
proxy_set_header Host $host;
}
location /api {
proxy_pass http://back-upstream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}