I'm trying to deploy my API to a VPS. I'm doing this using Dokku. The deployment process seemed to work well.
My initial port was 4000. I've accessed http://my_ip:4000 and I've noticed that my API worked.
The problem comes after I change the port to 80 using dokku proxy:ports-add http:80:4000
. After this, when I'm trying to access http://my_ip/
I receive the "Welcome to nginx" page.
Do you know any ways of fixing this?
(** I have to mention that I've used iptables -I INPUT 1 -p tcp --dport PORT_NUMBER -j ACCEPT
for ports 4000 and 80).
UPDATE: The content of nginx.conf from my dokku app:
server {
listen [::]:80;
listen 80;
server_name api.example.com;
access_log /var/log/nginx/api-access.log;
error_log /var/log/nginx/api-error.log;
location / {
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype appl> gzip_vary on;
gzip_comp_level 6;
proxy_pass http://api-4000;
proxy_http_version 1.1;
proxy_read_timeout 60s;
proxy_buffer_size 4096;
proxy_buffering on;
proxy_buffers 8 4096;
proxy_busy_buffers_size 8192;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-Start $msec;
}
include /home/dokku/api/nginx.conf.d/*.conf;
error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
location /400-error.html {
root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
internal;
}
error_page 404 /404-error.html;
location /404-error.html {
root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
internal;
}
error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
location /500-error.html {
root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
internal;
}
}
upstream api-4000 {
server 172.17.0.4:4000;
}
I had the same issue after deploying the first app on a Debian. This is (maybe) because I have set up the domain of my Dokku's app before deploying it.
So I did once again the same command : dokku domains:set my_app my_domain.com
and it worked...