0

I am trying to make it so that a request at path https://example.com/projects/pixelstacker/demo will serve static files that are located at /services/pixelstacker.web.net/wwwroot/dist. I want it to be located there so that I can keep related files closer together in the deployment system and file trees. It just makes it easier to manage. I'm having troubles getting this done in plesk because plesk does not allow you to make custom directives at the root / level for nginx.

The nginx configuration for my .net core app looks like this:

location /projects/pixelstacker/ {
    proxy_pass http://localhost:5005/;
    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-Host $host;
    proxy_set_header X-Real-IP $remote_addr; # remote IP addr again?
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # remote IP addr
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;
}

And then my configuration for my react app can do a basic proxy that WILL work, but only if the files for my react project are deployed to a publicly accessible folder. I'm trying to get this to work but for a folder that is located outside of the httpdocs directory instead. The public folder would be located at /httpdocs/projects/pixelstacker.web.react

# React
# https://stackoverflow.com/questions/53207059/react-nginx-routing-to-subdirectory
location ^~ /projects/pixelstacker/demo {
    alias /var/www/vhosts/example.com/httpdocs/projects/pixelstacker.web.react;
    try_files $uri $uri/ /projects/pixelstacker.web.react/index.html;
}

Any tips or advice? Thanks!

Pangamma
  • 731
  • 12
  • 28

0 Answers0