server {
        listen   8800;
        server_name localhost

        underscores_in_headers on;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #root C:/0_project/cdn;
        root /usr/share/nginx/html;

         location / {
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
            add_header Access-Control-Allow-Methods "GET, POST, OPTIONS,PUT,DELETE";
            try_files $uri $uri/ @router;
            index  index.html index.htm;
         }

         location ~ .*\.(eot|ttf|woff)$ {
    add_header Access-Control-Allow-Origin *;
         }
        location @router {
            rewrite ^.*$ /index.html last;
        }
    }

案例


vim /etc/nginx/conf.d/demo.conf

vim /opt/apps/nginx/demo.conf

docker cp /opt/apps/nginx/demo.conf 9f953ea6f065:/etc/nginx/conf.d/demo.conf
server {
        listen   8800;
        server_name localhost

        underscores_in_headers on;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #root C:/0_project/cdn;
        root /usr/share/nginx/html;

         location / {
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
            add_header Access-Control-Allow-Methods "GET, POST, OPTIONS,PUT,DELETE";
            try_files $uri $uri/ @router;
            index  index.html index.htm;
         }

         location ~ .*\.(eot|ttf|woff)$ {
    add_header Access-Control-Allow-Origin *;
         }
        location @router {
            rewrite ^.*$ /index.html last;
        }
    }
文档更新时间: 2023-08-22 23:20   作者:admin