需求:
项目url:http://127.0.0.1:18787/app/admin
变成好看的域名: http://invoice.xxxx.com
增加个server:
server { server_name invoice.buruyouni.com; listen 80; access_log on; location / {#访问域名直接到这里 proxy_pass http://127.0.0.1:18787/app/admin; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_http_version 1.1; proxy_set_header Connection ""; } location ~ ^/app/admin{#以/app/admin开头的,不加url以这开头的css/js/png等无法用 proxy_pass http://127.0.0.1:18787; } }
重启nginx