Https, is being configured. Https access to PHP file 403 forbidden occurs, and http access site is normal.

site environment: centos7+php+mysql+openresty (nginx)

uses Tencent Cloud"s one-year free certificate. After configuration, the website can display https, normally with https://www.mydomain.com/50x. and https://www.mydomain.com/info. tests. But visiting the home page and other webpage pages are all 403forbidden. All web pages accessed by http appear normal. Why is this happening? May I ask the students how to solve it?

error message: fail to load resource in cosole

error.log:

2018/07/11 07:55:22 [emerg] 5550-sharp5550: bind() to [::]:80 failed (98: Address already in use)

2018/07/11 07:55:22 [emerg] 5550-sharp5550: bind() to 0.0.0.0:443 failed (98: Address already in use)

post your own nginx.conf:

user root;

worker_processes 1;

-sharperror_log logs/error.log;

error_log logs/error.log debug;

-sharperror_log logs/error.log info;

pid logs/nginx.pid;

-sharperror_log /var/log/nginx/error.log debug;

-sharppid /var/run/nginx/nginx.pid;

events {

worker_connections  1024;
}

http {

include       mime.types;
default_type  application/octet-stream;

-sharplog_format  main  "$remote_addr - $remote_user [$time_local] "$request" "
-sharp                  "$status $body_bytes_sent "$http_referer" "
-sharp                  ""$http_user_agent" "$http_x_forwarded_for"";

-sharpaccess_log  logs/access.log  main;

sendfile        on;
-sharptcp_nopush     on;

-sharpkeepalive_timeout  0;
keepalive_timeout  65;

client_max_body_size 8m;    -sharp
client_body_buffer_size 2m;  -sharp

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;

gzip  on;

-sharpWAF
lua_shared_dict limit 50m;
lua_shared_dict guard_dict 100m;
lua_shared_dict dict_captcha 70m;
lua_package_path "/usr/local/openresty/nginx/conf/waf/?.lua";
init_by_lua_file "/usr/local/openresty/nginx/conf/waf/init.lua";
access_by_lua_file "/usr/local/openresty/nginx/conf/waf/access.lua";

server {
    listen       80;
    listen       [::]:80 ipv6only=on default_server;
    
    server_name  my.server.ip.here;

    -sharpcharset koi8-r;

    -sharpaccess_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.php index.html index.htm;
    }

    -sharperror_page  404              /404.html;

    -sharp redirect server error pages to the static page /50x.html
    -sharp
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    -sharp proxy the PHP scripts to Apache listening on 127.0.0.1:80
    -sharp
    -sharplocation ~ \.php$ {
    -sharp    proxy_pass   http://127.0.0.1;
    -sharp}

    -sharp pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    -sharp
    
    location ~ \.php$ {
        
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    -sharp deny access to .htaccess files, if Apache"s document root
    -sharp concurs with nginx"s one
    -sharp
    -sharplocation ~ /\.ht {
    -sharp    deny  all;
    -sharp}
}


-sharp another virtual host using mix of IP-, name-, and port-based configuration
-sharp
-sharpserver {
-sharp    listen       8000;
-sharp    listen       somename:8080;
-sharp    server_name  somename  alias  another.alias;

-sharp    location / {
-sharp        root   html;
-sharp        index  index.html index.htm;
-sharp    }
-sharp}


-sharp HTTPS server

server {
    listen  443 ssl http2;
    
    server_name  www.mydomainname.com;
    charset  utf-8;
    ssl on;
    default_type  text/plain;
    
   ssl_certificate       1_www.mydomainname.com_bundle.crt;
   ssl_certificate_key   2_www.mydomainname.com.key;
   

   ssl_session_cache    shared:SSL:1m;
   ssl_session_timeout  5m;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

   ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
   ssl_prefer_server_ciphers  on;

    location / {
        root   html;
        index  index.html index.htm index.php;
    }


     location ~ /phpmyadmin/.+\.php$ {
        if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
         set $valid_fastcgi_script_name $1;
        }
         include fastcgi_params;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
     }

    location ~ \.php$ {
        -sharp 
        fastcgi_pass   127.0.0.1:9000;
        -sharp  nginx ()
        fastcgi_index  index.php;
        -sharp 
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        -sharp  fastcgi 
        include        fastcgi_params;
    }



}
}
Mar.25,2021
Menu