1

First of all, thanks for reading my thread. Second, sorry for my English.

I'm trying to run an Asp.net core application in a raspberry but still facing some problems when proxying with nginx.

Basically I follow these tutorials to configure my workplace and export my project to arm, the only difference is that I've created a MVC application instead a simple Hello World:

http://www.protosystem.net/blog/aspnet-core-on-raspberry-pi/ http://www.protosystem.net/blog/aspnet-core-hello-world-on-raspberry-pi/

The problem starts when I execute the app. For default, it runs on port 5000, but when nginx do the proxy for port 80 it doesn't load the css.min, javascrip files and the Home directory according to the image below:

On the port 5000

Port 80

Follow the nginx configuration below:

server {
   listen 80 default_server;
          listen [::]:80 default_server;

          root /www/mywebsite;

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

          server_name _;


            location / {
            proxy_pass http://127.0.0.1:5000;
            proxy_set_header Connection "";
            proxy_http_version 1.1;
            proxy_set_header    Host $host;
            proxy_set_header    X-Real-IP   $remote_addr;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

             try_files $uri $uri/ =404;
            }}
2
  • 1
    Try removing the try_files. To me (might be wrong) it seems like you are saying pass everything to the proxy but then use try files which looks for the file in the file system. When not found it returns a 404. Commented Jan 9, 2018 at 16:49
  • It worked! Thanks for the help. Commented Jan 9, 2018 at 16:57

1 Answer 1

2

Per my comment I would suggest removing the try_files directive like so:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;

    root /www/mywebsite;
    index index.html index.htm index.nginx-debian.html;

    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP   $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    }}
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.