POST result: 404

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

POST result: 404

vergil
This is the nginx configuration in Ubuntu 18.04 :

    server {
        listen 443 ssl http2 default_server;
        server_name ggc.world;

        ssl_certificate /etc/letsencrypt/live/ggc.world/fullchain.pem; #
managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/ggc.world/privkey.pem; #
managed by Certbot

        ssl_trusted_certificate /etc/letsencrypt/live/ggc.world/chain.pem;

        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        ssl_session_timeout 5m;
        #ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-  
   
draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:50m;
        #ssl_stapling on;
        #ssl_stapling_verify on;

        access_log /var/log/nginx/ggcworld-access.log combined;

        add_header Strict-Transport-Security "max-age=31536000";
        location = /favicon.ico { access_log off; log_not_found off; }

        location / {
            proxy_pass <a href="http://127.0.0.1:8080;">http://127.0.0.1:8080;
            #proxy_pass <a href="http://127.0.0.1:2000;">http://127.0.0.1:2000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            #proxy_set_header Host $host;
        }
    }

    server {
        listen 80 default_server;
        listen [::]:80 default_server;
        error_page 497 <a href="https://$host:$server_port$request_uri;">https://$host:$server_port$request_uri;
        server_name ggc.world;
        return 301 https://$server_name$request_uri;

        access_log /var/log/nginx/ggcworld-access.log combined;

        add_header Strict-Transport-Security "max-age=31536000";
        location = /favicon.ico { access_log off; log_not_found off; }

        location / {
            proxy_pass <a href="http://127.0.0.1:8080;">http://127.0.0.1:8080;
            #proxy_pass <a href="http://127.0.0.1:2000;">http://127.0.0.1:2000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            #proxy_set_header Host $host;
        }
    }

    upstream websocket {
        ip_hash;
        server localhost:3000;
    }

    server {
        listen 81;
        server_name ggc.world;

        #location / {
        location ~ ^/(websocket|websocket\/socket-io) {
            proxy_pass <a href="http://127.0.0.1:4201;">http://127.0.0.1:4201;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwared-For $remote_addr;
            proxy_set_header Host $host;

            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
        }
    }

    upstream golang-webserver {
        ip_hash;
        server 127.0.0.1:2000;
    }

    server {
        listen 3000;
        server_name ggc.world;

        location / {
            proxy_pass http://golang-webserver;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            #proxy_set_header Host $host;
        }
    }

This is my vue.config.js file for the vue.js frontend:

    // vue.config.js
    module.exports = {
      // options...
      publicPath: '',
      devServer: {
        host: '0.0.0.0',
        port: 8080,
        //port: 2000,
        public: 'ggc.world'
      },
    }

And this is port configuration for go-webserver :

server-gorillamux.go :

    const (
            CONN_HOST = "192.168.1.7"
            CONN_PORT = "2000"
    )


Compiling the frontend:

     DONE  Compiled successfully in 1224ms                                  
        7:55:19 PM

      App running at:
      - Local:   http://localhost:8080 
      - Network: http://ggc.world/

      Note that the development build is not optimized.
      To create a production build, run npm run build.

And running the go-webserver:

    goServer$ go run server-gorillamux.go


I get this error: POST https://ggc.world/puser/add 404

These are the last lines of the nano /var/log/nginx/ggcworld-access.log file
:

    36.119.16 - - [30/Apr/2020:19:56:57 +0200] "GET / HTTP/2.0" 200 694 "-"
"Mozilla/5.0 (X11; Linux x86_64)  
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129
Safari/537.36"
    2.36.119.16 - - [30/Apr/2020:19:56:57 +0200] "GET /js/app.js HTTP/2.0"
200 147353 "https://ggc.world/" "Mozilla/5.0
    (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/81.0.4044.129 Safari/537.36"
    2.36.119.16 - - [30/Apr/2020:19:56:58 +0200] "GET /js/chunk-vendors.js
HTTP/2.0" 200 4241853 "https://ggc.world/"
    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/81.0.4044.129 Safa$
    2.36.119.16 - - [30/Apr/2020:19:56:58 +0200] "GET
/sockjs-node/info?t=1588269418560 HTTP/2.0" 200 79
    "https://ggc.world/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/81.0.4044.$
    2.36.119.16 - - [30/Apr/2020:19:57:21 +0200] "POST /puser/add HTTP/2.0"
404 137 "https://ggc.world/" "Mozilla/5.0
    (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/81.0.4044.129 Safari/537.36"

How can I solve the problem?
Looking forward to your kind help.
Marco

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287914,287914#msg-287914

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: POST result: 404

Thomas Ward
On 4/30/20 2:09 PM, MarcoI wrote:
This is the nginx configuration in Ubuntu 18.04 :

    server {
        listen 443 ssl http2 default_server;
        server_name ggc.world;

...

        location / {
            proxy_pass http://127.0.0.1:8080;

If I'm reading your config directly, this is passing port 443 to the backend here at port 8080 on the system locally.  Therefore, the 404 request could be coming from this backend.  Have you verified that this path actually works in your app when accessed directly on the system?  If it does not, then the backend app is at fault here.

 ...

And running the go-webserver:

    goServer$ go run server-gorillamux.go


I get this error: POST https://ggc.world/puser/add 404

... which is indicative of the issue because of the above mentioned proxy_pass block being on the app you've built/compiled.  If that backend doesn't have the capacity to handle the requested path it could return the 404 which would trickle back and show a 404 via the nginx server.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287914,287914#msg-287914

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx


Thomas


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: POST result: 404

vergil
Hi Thomas,
thank you for your kind help.

I'm not sure, due to my lack of knowledge, how I can check if the path from
port 443 to port 8080 works in my app when accessed directly on my system.

(base) marco@pc01:~$ sudo netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State  
   PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN  
   19569/nginx: master
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN  
   19569/nginx: master
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN  
   754/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN  
   1230/sshd          
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN  
   1035/cupsd          
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN  
   19569/nginx: master
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN  
   1321/postgres      
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN  
   19569/nginx: master
tcp        0      0 127.0.0.1:33917         0.0.0.0:*               LISTEN  
   1227/containerd    
tcp6       0      0 :::80                   :::*                    LISTEN  
   19569/nginx: master
tcp6       0      0 :::22                   :::*                    LISTEN  
   1230/sshd          
tcp6       0      0 ::1:631                 :::*                    LISTEN  
   1035/cupsd          

ports 80 and 443 seem both listening and owned by nginx.

How can I check if the backend has the capacity to handle the requested
path?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287914,287917#msg-287917

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: POST result: 404

Thomas Ward

On 4/30/20 3:20 PM, MarcoI wrote:
Hi Thomas,
thank you for your kind help.

...

How can I check if the backend has the capacity to handle the requested
path?

This is where you need to expand the knowledge into other tools such as `curl`.  On the system where nginx and your webapp run execute this:

    curl -X POST http://127.0.0.1:8080/puser/add

... if this 404s then you know that the issue is that your backend application written in Go doesn't accept this as a POST-able path.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287914,287917#msg-287917

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx


Thomas


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: POST result: 404

vergil
It doesn't produce a "404" but it is saying "Cannot POST" ...:

curl -X POST http://127.0.0.1:8080/puser/add
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /puser/add</pre>
</body>
</html>


These are the corresponding lines in /var/log/nginx :  

128.14.134.170 - - [01/May/2020:10:04:03 +0200] "GET / HTTP/1.1" 502 584 "-"
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/60.0.3112.113 Safari/537.36"
37.116.208.25 - - [01/May/2020:10:09:53 +0200] "GET / HTTP/2.0" 200 694 "-"
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/81.0.4044.129 Safari/537.36"
37.116.208.25 - - [01/May/2020:10:09:53 +0200] "GET /js/app.js HTTP/2.0" 200
147353 "https://ggc.world/" "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safar$
37.116.208.25 - - [01/May/2020:10:09:54 +0200] "GET /js/chunk-vendors.js
HTTP/2.0" 200 4241853 "https://ggc.world/" "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.404$
37.116.208.25 - - [01/May/2020:10:09:54 +0200] "GET
/sockjs-node/info?t=1588320594594 HTTP/2.0" 200 79 "https://ggc.world/"
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/$
37.116.208.25 - - [01/May/2020:10:10:15 +0200] "POST /puser/add HTTP/2.0"
404 137 "https://ggc.world/" "Mozilla/5.0 (X11; Linux x86_64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/$

And this is the nginx configuration file:

server {
    listen 443 ssl http2 default_server;
    server_name ggc.world;

    ssl_certificate /etc/letsencrypt/live/ggc.world/fullchain.pem; # managed
by Certbot
    ssl_certificate_key /etc/letsencrypt/live/ggc.world/privkey.pem; #
managed by Certbot

    ssl_trusted_certificate /etc/letsencrypt/live/ggc.world/chain.pem;

    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    ssl_session_timeout 5m;
    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers
EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:50m;
    #ssl_stapling on;
    #ssl_stapling_verify on;

    access_log /var/log/nginx/ggcworld-access.log combined;

    add_header Strict-Transport-Security "max-age=31536000";
    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        proxy_pass <a href="http://127.0.0.1:8080;">http://127.0.0.1:8080;
        #proxy_pass <a href="http://127.0.0.1:2000;">http://127.0.0.1:2000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        #proxy_set_header Host $host;
    }
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    error_page 497 <a href="https://$host:$server_port$request_uri;">https://$host:$server_port$request_uri;
    server_name ggc.world;
    return 301 https://$server_name$request_uri;

    access_log /var/log/nginx/ggcworld-access.log combined;

    add_header Strict-Transport-Security "max-age=31536000";
    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        proxy_pass <a href="http://127.0.0.1:8080;">http://127.0.0.1:8080;
        #proxy_pass <a href="http://127.0.0.1:2000;">http://127.0.0.1:2000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        #proxy_set_header Host $host;
    }
}

# https://www.nginx.com/blog/nginx-nodejs-websockets-socketio/
# https://gist.github.com/uorat/10b15a32f3ffa3f240662b9b0fefe706
# http://nginx.org/en/docs/stream/ngx_stream_core_module.html

upstream websocket {
    ip_hash;
    server localhost:3000;
}

server {
    listen 81;
    server_name ggc.world;

    #location / {
    location ~ ^/(websocket|websocket\/socket-io) {
        proxy_pass <a href="http://127.0.0.1:4201;">http://127.0.0.1:4201;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwared-For $remote_addr;
        proxy_set_header Host $host;

        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
#
https://stackoverflow.com/questions/40516288/webpack-dev-server-with-nginx-proxy-pass


upstream golang-webserver {
    ip_hash;
    server 127.0.0.1:2000;
}

server {
    listen 2999;
    server_name ggc.world;

    location / {
        #proxy_pass <a href="http://127.0.0.1:8080;">http://127.0.0.1:8080;
        proxy_pass http://golang-webserver;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        #proxy_set_header Host $host;
    }
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287914,287919#msg-287919

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: POST result: 404

vergil
I tried to curl POST the entire form:

(base) marco@pc01:/var/log/nginx$ curl -X POST -F 'first_name=pinco' -F
'last_name=pallo' -F 'company_name=Company' -F
'email=[hidden email]' -F 'tel=111111111'
http://127.0.0.1:8080/puser/add 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /puser/add</pre>
</body>
</html>

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287914,287920#msg-287920

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx