• nginx配置的config文件


    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
        server {
            listen       8009;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
                #前端Vue-router 设置为history模式----↓这行必须加
                try_files $uri $uri/ /index.html;
            }
    
            #配置跨域问题 ↓   项目中的baseUrl 为let baseUrl = "/api"
            location /api/ {
                # 地址是假的,这个是后端的地址填自己的
                proxy_pass http://47.104.81.202:8002;
                # 这句话的意思是对路由进行重写,因为/api为代替后端地址的写在前端项目里,所以在访问的时候不加在后端路径会多加一个api,重写是为了去掉
                rewrite "^/api/(.*)" /$1  break;
            }
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ .php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ .php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /.ht {
            #    deny  all;
            #}
        }
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    
        # HTTPS server
        #
        #server {
        #    listen       443 ssl;
        #    server_name  localhost;
    
        #    ssl_certificate      cert.pem;
        #    ssl_certificate_key  cert.key;
    
        #    ssl_session_cache    shared:SSL:1m;
        #    ssl_session_timeout  5m;
    
        #    ssl_ciphers  HIGH:!aNULL:!MD5;
        #    ssl_prefer_server_ciphers  on;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    }
  • 相关阅读:
    如何更高效(HOWTO: Be more productiveAaron Swartz)
    这事儿太丢人了
    2012年终极心愿之每月培养一个好习惯
    【转载】SQLLite使用入门
    【原创】XNA 4.0学习笔记之如何使用XACT给Cue添加多个音频
    【原创】编程日记之——如何对DataSet进行强类型化
    【索引】Win7 操作系统编程常识
    [原创]怎么降低Winform程序占用的内存
    【原创】自制Winform标签控制控件[支持不规则窗体]
    【原创】XNA 4.0学习笔记之绘制基元图形的几种PrimitiveType区别[PS:4.0似乎有所改动]
  • 原文地址:https://www.cnblogs.com/enhengenhengNymph/p/14657305.html
Copyright © 2020-2023  润新知