亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

nginx反向代理apache動靜分離,路由不正常跳轉

nginx反向代理apache動靜分離,路由不正常跳轉

PHP
海綿寶寶撒 2019-03-18 18:07:28
運行環境: centos7 php7.1 nginx 1.10 apache 2.4 php框架phalcon nginx.conf配置 upstream lamp{ server 127.0.0.1:81 weight=1 max_fails=3 fail_timeout=30s; } server { listen 80; server_name we.test.com; index index.php root /wwwroot/test/public; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ .*\.(php|jsp|cgi)?$ { 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_pass http://lamp; } location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { root /wwwroot/test/public; expires 3d; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } apache vhost配置 <VirtualHost *:81> ServerName we.test.com DocumentRoot /wwwroot/test/public <Directory wwwwroot/test/public> Options FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all Require All granted </Directory> </VirtualHost> .htaccess 文件 (在public目錄下) AddDefaultCharset UTF-8 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] </IfModule> 當我訪問 we.test.com:81的時候所有的路由可以正常訪問 例如 we.test.com/user/login 或者 接受 參數 we.test.com/article/index?id=5 但是當我 訪問 nginx監聽的80端口 ,所有的訪問都很奇怪,就是瀏覽器的url會變成對應的路由 例如we.test.com/user/login 但是 頁面展示的內容 還是 we.test.com的默認頁,只是刷新了一下。 剛剛嘗試這種 nginx 反向代理 apache ,不知道有沒有大神可以幫忙解答一下。非常非常感謝。 如有有缺少的條件,我會及時回復 在線等。。。
查看完整描述

1 回答

?
回首憶惘然

TA貢獻1847條經驗 獲得超11個贊

apache不需要更改,nginx配置改一下

location / {
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php?$1 last;
                }
        }
        location ~ \.php$ {
         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_pass http://lamp;
        }                               
查看完整回答
反對 回復 2019-03-18
  • 1 回答
  • 0 關注
  • 566 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號