Nginx中的反向代理

时间:2020-04-15 14:57:17

标签: nginx

我希望我的根域中的/ api重定向到端口8000上运行的应用程序

I tried adding the following code :

        root /var/www/html/dexhub/client/build;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name mydomain.com.com www.mydomain.com;

        error_page 404 /;


        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        location /api {
         proxy_pass http://localhost:8000;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection 'upgrade';
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;
        }

我在这里做什么错了。

0 个答案:

没有答案