Here's what I have in my /etc/nginx/sites-available/ folder
allverse.co
server {
listen 80;
server_name allverse.co www.allverse.co;
root /var/www/allverse;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
jademgr.com
server {
listen 80;
server_name jademgr.com www.jademgr.com;
root /var/www/jademgr;
location / {
proxy_pass http://localhost:5010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
I have them running under supervisor.
[program:jademgr]
command=/usr/bin/dotnet /var/www/jademgr/jademgr.dll
directory=/var/www/jademgr/
autostart=true
autorestart=true
stderr_logfile=/var/log/jademgr.err.log
stdout_logfile=/var/log/jademgr.out.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=www-data
stopsignal=INT
allverse
[program:allverse]
command=/usr/bin/dotnet /var/www/allverse/allverse.dll
directory=/var/www/allverse/
autostart=true
autorestart=true
stderr_logfile=/var/log/allverse.err.log
stdout_logfile=/var/log/allverse.out.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=www-data
stopsignal=INT
I have allverse set to run on port 5000 and jademgr set to run on port 5010. What am I doing wrong? When I start both sites they both point to the same jademgr site.
Thanks.
Related
Cannot start Tomcat 9 with Nginx in ubuntu(22.04).
Here is my Nginx setting:
server {
listen [::]:80;
listen 80;
server_name 35.221.197.155;
location / {
proxy_pass http://0.0.0.0:8080;
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;
}
}
Any wrong setting here? Please tell me.
I run my server app with command: ng serve and get error in browser console:
Firefox cannot connect to the wss://dev.domain.com/ws server.
[webpack-dev-server] Trying to reconnect...
or on chrome:
WebSocket connection to 'wss://dev.domain.com/ws' failed
[webpack-dev-server] Disconnected!
[webpack-dev-server] Trying to reconnect...
My config nginx is:
location ^~ / {
proxy_pass http://localhost:4200;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
}
location ^~ /sockjs-node/ {
proxy_pass http://localhost:4200;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
}
location ^~ /ws/ {
proxy_pass http://localhost:4200;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
}
This should work, but it doesn't. my configuration is wrong?
That works for me for Angular 14 :
location /ng-cli-ws {
proxy_pass http://host-gateway:4200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
If your app is using /ws, try to remove ending slash, else nginx responds with 301 to /ws/...
I second Vlad's answer, but I would like to elaborate on the solution.
I wanted my Angular application to be able to reload any changes at development time and be able to display them through HTTPS. So the following is what is working fine for me. It includes configuration managed by Certbot; and omits an additional default server block.
upstream frontend {
server 0.0.0.0:4200 fail_timeout=3s max_fails=3;
server 0.0.0.0:80 backup;
}
upstream wsfront {
ip_hash;
server 0.0.0.0:4200;
}
server {
server_name my.domain.net;
location ~ ^/ng-cli-w(s|s/)$ {
proxy_pass http://wsfront;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location / {
proxy_pass http://frontend;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/my.domain.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my.domain.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = my.domain.net) {
return 301 https://$host$request_uri;
}
listen 80 ;
listen [::]:80 ;
server_name my.domain.net;
return 404;
}
I've configured nginx to forward HTTP to HTTPS. This works for everything except my reverse proxy websites (that are also configured in nginx). I am getting the error ERR_TOO_MANY_REDIRECTS in my web browser for reverse proxy sites. I'm not sure what I'm doing wrong.
Below, is the configuration I'm using in nginx.conf:
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
location / {
root "C:\inetpub\wwwroot";
index index.html index.htm;
}
location /files {
proxy_pass http://localhost:89;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /photos {
proxy_pass http://localhost:89/photos/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
I want to listen to ports with nginx and set the proxy.
here is the conf of the server
server{
listen 8080;
location / {
proxy_pass http://127.0.0.1:82;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-live;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server{
listen 8081;
location / {
proxy_pass http://127.0.0.1:83;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-live;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
the 8080 is ok but the 8081 can not be connected
The sample might help you. I think this is a duplicate of Nginx multiple ports
server {
listen 80;
listen 8000;
server_name example.org;
root /var/www/;
}
I'm new to nginx and I'm trying to get my second.domain.com to display the contents of first.domain.com/dir, ( running on port 3000 of my localhost ) after looking online it seems this is the solution
# this one works fine
server {
listen 80;
server_name first.domain.com;
location / {
proxy_pass http://localhost: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;
}
}
# this one doesn't work as expected
server {
listen 80;
server_name second.domain.com;
location / {
proxy_pass http://localhost: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;
root /dir;
index index.html;
}
}
but when I visit second.domain.com I'm getting the same root as first.domain.com rather than first.domain.com/dir ...can anyone see what I'm doing wrong?
riffing off of mim's comment, I got it to work this way
# this one is now working as planned :)
server {
listen 80;
server_name second.domain.com;
location / {
# added mim's suggestiong here
rewrite /folder/(.*) /$1 break;
# then added the folder after the port
proxy_pass http://localhost:3000/folder;
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;
root /dir;
index index.html;
}
}