一,配置 nginx
1,在一个nginx的server段中添加如下内容:
location /index.php {
try_files /not_exists @octane;
}
location / {
try_files $uri $uri/ @octane;
}
location @octane {
set $suffix "";
if ($uri = /index.php) {
set $suffix ?$query_string;
}
# 这里指向代理地址
proxy_pass http://127.0.0.1:8000$suffix;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_intercept_errors on;
proxy_next_upstream error timeout http_500;
}
说明:8000是octane的守护端口
2,一个例子:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
# root /var/www/html;
root /data/api/public;
# Add index.php to the list if you are using PHP
# index index.php index.html index.htm index.nginx-debian.html;
index index.php;
server_name _;
location /index.php {
try_files /not_exists @octane;
}
location / {
try_files $uri $uri/ @octane;
}
location @octane {
set $suffix "";
if ($uri = /index.php) {
set $suffix ?$query_string;
}
# 这里指向代理地址
proxy_pass http://127.0.0.1:8000$suffix;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_intercept_errors on;
proxy_next_upstream error timeout http_500;
}
}
二,完成之后重启nginx服务
# systemctl restart nginx.service
然后可以通过nginx的域名和端口访问
标签:laravel,11,set,index,server,nginx,proxy,octane From: https://www.cnblogs.com/architectforest/p/18535075