403 forbidden behind nginx

I can test my vapor sample under localhost:8080, but with nginx proxy on 80 to 127.0.0.1:8080, the page keeps on showing 403 forbidden. What should I do now?

root /home/zhaoxin/vapor/hello;

localhost is not equivalent to 127.0.0.1, you should keep your Vapor app and Nginx proxy aligned.

Somehow the sample on the official site didn't work.

Vapor: Deploy → Nginx didn't work.

But I followed another article and this worked.

So I guess the nginx conf file was not correct.

----Here is the working conf I used----

server {
    server_name vapor.parussoft.com;
    listen 80;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    try_files $uri @proxy;
    location @proxy {
        proxy_pass http://127.0.0.1:8080;
        proxy_pass_header Server;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass_header Server;
        proxy_connect_timeout 3s;
        proxy_read_timeout 10s;
    }
}

-- comparing with the sample---

server {
    server_name hello.com;
    listen 80;

    root /home/vapor/Hello/Public/;

    location @proxy {
        proxy_pass http://127.0.0.1:8080;
        proxy_pass_header Server;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass_header Server;
        proxy_connect_timeout 3s;
        proxy_read_timeout 10s;
    }
}

This is deploy article

1 Like
Terms of Service

Privacy Policy

Cookie Policy